From: Dave Coventry
Subject: Autolisp: Converting a direction vector into a VRML Euler
Date: 
Message-ID: <2226e0d5.0312040049.12e59d08@posting.google.com>
Hi,

I'm trying to convert a 3-float direction vector into a 4-float Euler
suitable for VRML.

The VRML default is be the plan view, which could be defined as a
3-float vector(0,0,-1) which would indicate looking down from the
origin.

The 4-float Euler represents rotation from this default about an axis
defined by a directional Vector (as I understand it).

So a cylinder standing up on it's end would be the default. If you
wanted to represent a cylinder lying on the ground and pointing away
from the viewer, that cylinder would be rotated around the x axis by
90 deg (1.57 radians) in the following way:

rotation 1 0 0 1.57

So, in order to convert this I would need to find the normal to the
plane defined by my direction vector and the euler default direction
vector and rotate by the angle between them.

To get the normal I nee the cross Product:

(defun crossProduct(VectorA VectorB)
  (list
    (- (* (cadr VectorA) (caddr VectorB))(* (caddr VectorA) (cadr
VectorB)))
    (- (* (caddr VectorA) (car VectorB))(* (car VectorA) (caddr
VectorB)))
    (- (* (car VectorA) (cadr VectorB))(* (cadr VectorA) (car
VectorB)))
  )
)

However, this does not produce the expected result.

Can anyone see what I'm doing wrong?

Can anyone suggest a better solution?

Many thanks,

Dave Covenrty