How do I ADD gravitation to a rotation matrix?

| | August 4, 2015

I have ported the Matlab script from to POV-Ray and everything works fine (although I’m not quite sure why). To navigate a “turtle” through space, it utilizes a 3D rotation matrix (roll/pitch/yaw).

Now I would like to add a “tropism” command to simulate gravity pulling on the elements of an L-System, similar to how Laurens Lapr├ęs LParser does, and this is where I’m stuck.

This sounds trivial maybe, but I’ve been hitting walls for the past week, google and dissecting Lparser source code didn’t help a bit:

What operation must be performed to “add” a gravity vector to the rotation matrix, iow: how do I easily rotate x degrees towards (0, -1, 0)?

—If it is of any help, this is a simplified example of how my script performs a YAW of dA radians. The columns of the matrix are stored in three vectors hT, lT, uT. For each, macro Rup(Vector, Angle) is called and returns the new vector (column of the matrix).

Corresponding macros Rlp & Rhp for pitch and roll exist, of course. vdot(A, B) is a POV Ray function and returns the dot product of A and B.

#if (cmdT = "+")   
            #declare hT=Rup(hT, dA);
            #declare lT=Rup(lT, dA);
            #declare uT=Rup(uT, dA);

#macro Rup(RotVec, Angle)
    #local RotX=vdot(RotVec, < cos(Angle),  sin(Angle),      0>);
    #local RotY=vdot(RotVec, <-sin(Angle),  cos(Angle),      0>);
    #local RotZ=vdot(RotVec, < 0,           0,               1>);
    <RotX, RotY, RotZ>

It works perfectly, but I don’t know why so I don’t know what to do to add gravitation. Thanks in advance!

One Response to “How do I ADD gravitation to a rotation matrix?”

  1. Robert Eastwood on November 30, -0001 @ 12:00 AM

    Sounds like your talking about inertial force, if right go further right, that sounds like interia.

    Record previous movement use that as inertia value. If rocket adds rotation of x, it will same rotation for every iteration of x time.

    If you are talking about gravity, isn’t that just a translation of the object some distance based on current speed * time since last computation, and where the speed is increased each tick by the formula of acceleration of gravity?

    If your talking about rotating like a falling building, then part of the vector is canceled at first by the reverse force of the ‘structure’ holding it up(why non leaning buildings don’t fall) once you find the pivot point, the force of the building holding up the weight, and the direction of gravity are added, and they move the point outward. If at 15 degree tilt, most of the force of rigidity counters most of the gravity, but some continues to push it outward. As it gets further out, the rigidity is at a different angle, and more of that force is pushing outward.

    But I might not know at all what your talking about. Sounds like your trying to deduce gravity of an object that has some ridgid structure as another force.

Leave a Reply