ang_for_axis(ANGLE* vAng, VECTOR* vAxis, var angle)

LC Konvertiert eine Drehung um eine beliebige Achse in einen Eulerwinkel. Läßt sich dazu verwenden, Entities um beliebige Achsen zu drehen.

Parameter:

vAng Pointer auf einen Winkelvektor.
vAxis Pointer auf einen Richtungsvektor, der als Drehachse dient.
angle Drehung um ut vAxis in 0..360 Grad im Gegenuhrzeigersinn.

Geschwindigkeit:

Mittel

Beispiel (lite-C):

// calculate rotation for aligning an axis to a normal vector
function ang_align(ANGLE* ang, VECTOR* to, VECTOR* axis) 
{
vec_normalize(axis,1);
vec_normalize(to,1); // calculate a rotation axis perpendicular to both vectors
VECTOR rot;
vec_cross(rot,axis,to);
// rotate by the angle difference between both vectors
ang_for_axis(ang,rot,acosv(vec_dot(to,axis)));
}
... // align an entity to the floor normal c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME); // set floor normal hit.nx ang_align(my.pan,hit.nx,vector(0,0,1)); // align vertical axis to the floor normal ang_rotate(my.pan,vector(angle,0,0)); // rotate the entities' pan angle ...

Siehe auch:

vec_to_angle, vec_rotate, ang_rotate, ang_for_matrix

► latest version online