    # Thread: Calculate next polar coordinate if line is not straight

1. Login to Give a bone

## Calculate next polar coordinate if line is not straight

Dear ,

I want to move an object (car object) on road object(which has turns i.e S type road) , i am calculating the polar coordinate based on the angle between two points distance between two points and moving the car object to the next polar coordinate it works fine if road is straight , but how to calculate next point if road is not straight.

Please help me on this .

(defun c:newmove ( / ss pt)
(princ "\r Move Car ")
(setq ss (entsel))
(setq pt1 (getpoint "\nSelect base point: "))
(setq forang2 (getpoint "\nSelect another point on road to calculate angle: "))
(setq ang1 (apply 'atan (cdr (reverse (mapcar '- forang2 pt1)))))
(setq pt2 (polar pt1 ang1 0.0004))
(setq ang2 (apply 'atan (cdr (reverse (mapcar '- pt2 forang2)))))
(setq pt3 (polar pt2 ang2 0.0004))
(setq ang3 (apply 'atan (cdr (reverse (mapcar '- pt3 pt2)))))
(prin1 ang3)
(setq pt4 (polar pt3 ang3 0.0004))
(setq dis4 (distance pt3 pt4))
(setq ang4 (apply 'atan (cdr (reverse (mapcar '- pt4 pt3)))))
(setq pt5 (polar pt4 ang4 0.0004))
(setq ang5 (apply 'atan (cdr (reverse (mapcar '- pt5 pt4)))))
(setq pt6 (polar pt5 ang5 0.0004))
(setq ang6 (apply 'atan (cdr (reverse (mapcar '- pt6 pt5)))))
(setq pt7 (polar pt6 ang6 0.0004))
(setq ang7 (apply 'atan (cdr (reverse (mapcar '- pt7 pt6)))))
(setq pt8 (polar pt7 ang7 0.0004))
(setq ang8 (apply 'atan (cdr (reverse (mapcar '- pt8 pt7)))))
(setq pt9 (polar pt8 ang8 0.0004))
(command "._move" ss "" pt1 pt2)
(command "DELAY" 10000)
(command "._move" ss "" pt2 pt3)
(command "DELAY" 10000)
(command "._move" ss "" pt3 pt4)
(command "DELAY" 10000)
(command "._move" ss "" pt4 pt5)
(command "DELAY" 10000)
(command "._move" ss "" pt5 pt6)
(command "DELAY" 10000)
(command "._move" ss "" pt6 pt7)
(command "DELAY" 10000)
(command "._move" ss "" pt7 pt (command "DELAY" 10000)
(command "._move" ss "" pt8 pt9)
(command "DELAY" 10000)
(princ "\nEnter LazyMove to run program")
)

Thanks,

Sanjay  Reply With Quote

2. Login to Give a bone

## Re: Calculate next polar coordinate if line is not straight

I'd love to see this finished, but to account for steering limits, various wheelbases & tracking, and trailers makes for an extremely complex program.
You should look at AutoTurn & AutoTrack. They handle this nicely.  Reply With Quote

#### Tags for this Thread

angle between points, polar coordinate #### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•