My above explanation regarding the '
trans' method was quite poor, so I have spent some time constructing a diagram that will hopefully explain the method with more clarity.
I shall link you to the image, since it is rather large for the post:
Trans DiagramThe part of the code we are concerned with is:
(
(lambda ( n )
(- (caddr (trans (cadr g) 1 n)) (caddr (trans p 1 n)))
)
(polar '(0. 0. 0.) a 1.)
)
On my diagram I have labelled the
Base Point ['
p' in the code], and a diagrammatic cursor represents the
Cursor Position ['
(cadr g)' in the code]. The
WCS is shown in
cyan in the diagram.
Now, I define a coordinate system with Normal vector at an angle '
a' to the
WCS X-Axis, this coordinate system I have shown in
green. The normal vector in the code is the unit vector:
(polar '(0. 0. 0.) a 1.)
For
WCS this vector would be
'(0.0 0.0 1.0).
In this coordinate system, just need to check the difference in elevation (Z-Value) between the Cursor position (transformed to be relative to the new Coordinate System) and the Base Point (also transformed to be expressed relative to the new Coordinate System). These elevations are shown in dashed
red in the diagram.
Hence, as shown in the code:
(- (caddr (trans (cadr g) 1 n)) (caddr (trans p 1 n)))
I subtract the Z-Coordinate of the transformed Cusor Position from the Z-Coordinate of the transformed Base Point, if negative, the cursor is below the X-Axis of the defined coordinate system, and hence the direction needs to be reversed.
I hope this is clearer - if you have any questions, just ask.
Lee