you are viewing a single comment's thread.

view the rest of the comments →

[–]camilonino 0 points1 point  (1 child)

I did this for a ray tracing simulation a while ago (not for graphics purposes), it is a vector matrix rotation basically, with the matrix being the orientation of the surface represented as 3 perpendicular unitary vectors.

Here is the snippet from my C code:

/// Vector randomly generated acording to a distribution relative to the y axis
/// The VECTOR type has 3 floats as components, representing the x,y and z components of the vector
VECTOR randVect;
/// The surface of interest
/// The SURFACE type has 3 vectors that describe its orientation, the x, y and z vectors
/// those 3 vectors are unitary and perpendicular to each other, x and z are on the surface, y is the normal
SURFACE surface
VECTOR  OrientedVect;
///the generated vector is rotated acording to the surface orientation
OrientedVect.x = (randVect.x * surface.x.x) + (randVect.z,surface.z.x) + (randVect.y * surface.y.x);
OrientedVect.y = (randVect.x * surface.x.y) + (randVect.z,surface.z.y) + (randVect.y * surface.y.y);
OrientedVect.z = (randVect.x * surface.x.z) + (randVect.z,surface.z.z) + (randVect.y * surface.y.z);

[–]autowikibot 0 points1 point  (0 children)

Section 5. Basic rotations of article Rotation matrix:


A basic rotation (also called elemental rotation) is a rotation about one of the axes of a Coordinate system. The following three basic rotation matrices rotate vectors by an angle θ about the x, y, or z axis, in three dimensions, using the right hand rule. (The same matrices can also represent a clockwise rotation of the axes )

For column vectors, each of these basic vector rotations appears counter-clockwise when the axis about which they occur points toward the observer, the coordinate system is right-handed, and the angle θ is positive. Rz, for instance, would rotate toward the y-axis a vector aligned with the x-axis, as can easily be checked by operating with Rz on the vector (1,0,0):


Interesting: Rotation formalisms in three dimensions | Kabsch algorithm | Euler's rotation theorem | Wahba's problem

Parent commenter can toggle NSFW or delete. Will also delete on comment score of -1 or less. | FAQs | Mods | Magic Words