Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get a point if I know the angle and distance and starting point

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
cncah
928 Views, 2 Replies

How to get a point if I know the angle and distance and starting point

Hello, I'm wondering if anyone can tell me how to find the point where I can start my polyline in AutoLisp. I know all the vertices of my polyline, but I'm looping through the list of vertices, and I know the third and fourth points of the polyline. I know the previous and following points, what I want to do is start my polyline 0.5 at an angle towards the previous point. Go to the two points I already know, then end my polyline 0.5 towards the following point. I am able to get the angle towards the direction I want to go. But I'm not a math wiz and don't know what the best way would be to do this. I know how to do this typing the commands in at the command line, but need to know how to do this in AutoLisp. Any help  would be appreciated. Thanks.

2 REPLIES 2
Message 2 of 3
p_mcknight
in reply to: cncah

polar

Returns the UCS 3D point at a specified angle and distance from a point

(polar pt ang dist)
pt
A 2D or 3D point
ang
An angle expressed in radians relative to the world X axis. Angles increase in the counterclockwise direction, independent of the current construction plane
dist
Distance from the specified pt
 
angle
Returns an angle in radians of a line defined by two endpoints
(angle pt1 pt2)
 
So, if you know your two points and you want a point a certain distance 'X' from pt1 towards pt2 then the code would look something like
(polar pt1 (angle pt1 pt2) X)
Message 3 of 3
cncah
in reply to: p_mcknight

That is so much easier than the way I found how to do it late last night! I researched online and found a math website that showed how to get the point using the sine and cosine and it worked, but made for way more code than yours. Here is what I ended up with last night:

       (setq ang1 (angle vtpt2 vtpt1))
       (setq ang2 (angle vtpt3 vtpt4))

       (setq startpt (list (+ (car vtpt2) (* 0.5 (cos ang1))) (+ (cadr vtpt2) (* 0.5 (sin ang1)))))
       (setq endpt (list (+ (car vtpt3) (* 0.5 (cos ang2))) (+ (cadr vtpt3) (* 0.5 (sin ang2)))))

 Your way is much better and easier for me to understand:

(setq startpt (polar vtpt2 (angle vtpt2 vtpt1) 0.5))

 Thanks for the help!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost