trans

trans

The trans function translates coordinates from one coordinate system to another. See on-line help for details.

This can be confusing because "from one coordinate system to another" is difficult if you only have a choice between the current UCS (1) and World UCS (0). Plan of approach in Lisp:

If we convert those steps into code, the following sample fragments can help:

Save current UCS:

(if (not current-ucs-tmp)
   (setq current-ucs-tmp (list (getvar "ucsorg") (trans (list 1 0 0) 1 0) (trans (list 0 1 0) 1 0)))
)

WCS:

(command "._ucs" "_w")

Collect points:

(setq
   pt-a (getpoint (tra "\nSpecify apex point: "))
   pt-1 (getpoint (tra "\nSpecify end point 1: "))
   pt-2 (getpoint (tra "\nSpecify end point 2: "))
)

Create a new UCS:

(command "._ucs" "_3p" "_non" pt-a "_non" pt-1 "_non" pt-2)

Do something with the points, below shows how points behave and how they can be manipulated.

(princ (strcat "\nAngle from apex to point 2 in WCS is: " (rtos (angle pt-a pt-2)) "."))
(princ (strcat "\nAngle from apex to point 2 in plane trough points with point 1 on x-axis is: " (rtos (angle (trans pt-a 0 1) (trans pt-2 0 1))) "."))

Back to where we started:

(if current-ucs-tmp ; restore ucs
   (progn
      (command "._ucs" "_3p" (trans (nth 0 current-ucs-tmp) 0 1) (trans (nth 1 current-ucs-tmp) 0 1) (trans (nth 2 current-ucs-tmp) 0 1))
      (setq current-ucs-tmp nil)
   )
)

trans (laatst bewerkt op 2019-03-13 14:22:58 door WiebeVanDerWorp)