Create a Ray in ECMA?

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

Create a Ray in ECMA?

Post by wildspidee » Wed Feb 18, 2015 6:59 pm

Andrew,

Husky provided a very nice demonstration for me and he was using Rays. I couldn't locate anything in the API documentation regarding Rays and the Line2P.js didn't help me.
Can I create a Ray using code?

Thanks,
Lori

User avatar
andrew
Site Admin
Posts: 9058
Joined: Fri Mar 30, 2007 6:07 am

Re: Create a Ray in ECMA?

Post by andrew » Thu Feb 19, 2015 9:19 am

Yes, you can create any supported entity type in scripts. Example ray that starts at 100,50 and extends towards the right (1,0). I.e. the second vector is a direction vector.
new RRayEntity(document, new RRayData(new RVector(100,50), new RVector(1,0));

wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

Re: Create a Ray in ECMA?

Post by wildspidee » Thu Feb 19, 2015 5:06 pm

I should have searched RRay in the documentation, it was there all along.

I tried to implement this and had some strange results. When I created horizontal guides using rays, I was able to use a circle intersection with them. My vertical guides made of rays don't work with the circle intersection.

You can see that the circle definitely intersects the rays.
RayIntersect.jpg
RayIntersect.jpg (22.82 KiB) Viewed 6394 times
Here's the horizontal ones. There are two starting at the center out. The intersections are clear and found by QCAD.
RaysHoriz.jpg
RaysHoriz.jpg (26.78 KiB) Viewed 6394 times
I understand that Rays are probably virtual, being infinite, but it's strange that some work and others don't. Any ideas?

Lori

User avatar
andrew
Site Admin
Posts: 9058
Joined: Fri Mar 30, 2007 6:07 am

Re: Create a Ray in ECMA?

Post by andrew » Thu Feb 19, 2015 5:12 pm

Please post the drawing file, thanks.

wildspidee
Full Member
Posts: 84
Joined: Sat Nov 03, 2012 2:00 am

Re: Create a Ray in ECMA?

Post by wildspidee » Thu Feb 19, 2015 6:49 pm

Andrew

Here's the dxf. It is being generated from one of my .js files. I just commented everything below the drawing of the circle out (since the next bit of code was the intersection call that fails).

Thank you,
Lori
Attachments
VertRays.dxf
(99.6 KiB) Downloaded 506 times

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”