LDView 4.2 Released


RE: LDView 4.2 Released
#26
(2017-10-22, 4:16)Travis Cobbs Wrote:
(2017-10-22, 0:24)Michael Horvath Wrote: Could you explain this more? I thought that "camera.rotate" takes three Euler angles as input. Am I wrong? I have written a routine for another program that can convert a matrix to Euler angles, and could adapt that to here. Will that approach not work?

LDLCamera::rotate should in fact take the Euler angles, but a transformation matrix has a lot more in it than just that. If you have a rotation-only transformation matrix, then what you're doing is probably fine.

Will this create the correct type of matrix?

Code:
        TCFloat identity[16] =
        {
            1.0, 0.0, 0.0, 0.0,
            0.0, 1.0, 0.0, 0.0,
            0.0, 0.0, 1.0, 0.0,
            0.0, 0.0, 0.0, 1.0
        };
        TCVector::calcRotationMatrix(cameraXRotate, cameraYRotate, identity);

Also, I have written a matrix to euler converter in Lua for another project. Could someone explain how to convert it to C++?

Code:
-- Adapted from https://www.geometrictools.com/Documentation/EulerAngles.pdf, section 2.6
function MatrixToEuler(in_matrix)
    local r00 = in_matrix[9]
    local r01 = in_matrix[8]
    local r02 = in_matrix[7]
    local r10 = in_matrix[6]
    local r11 = in_matrix[5]
    local r12 = in_matrix[4]
    local r20 = in_matrix[3]
    local r21 = in_matrix[2]
    local r22 = in_matrix[1]
    local angleX = 0
    local angleY = 0
    local angleZ = 0
    if (r20 < 1) then
        if (r20 > -1) then
            angleX = atan2(r10, r00)
            angleY = asin(-r20)
            angleZ = atan2(r21, r22)
        else
            angleX = -atan2(-r12, r11)
            angleY = 90
            angleZ = 0
        end
    else
        angleX = atan2(-r12, r11)
        angleY = -90
        angleZ = 0
    end
    return {angleX, angleY, angleZ}
end
Reply
« Next Oldest | Next Newest »



Messages In This Thread
LDView 4.2 Released - by Travis Cobbs - 2016-07-11, 21:59
RE: LDView 4.2 Released - by Trevor Sandy - 2016-07-15, 11:44
RE: LDView 4.2 Released - by Travis Cobbs - 2016-07-15, 17:00
RE: LDView 4.2 Released - by Trevor Sandy - 2016-07-15, 17:15
RE: LDView 4.2 Released - by Michael Horvath - 2016-07-28, 11:23
RE: LDView 4.2 Released - by David Manley - 2016-09-14, 21:05
RE: LDView 4.2 Released - by Travis Cobbs - 2016-09-14, 22:06
RE: LDView 4.2 Released - by Michael Horvath - 2016-10-23, 20:24
RE: LDView 4.2 Released - by Travis Cobbs - 2016-10-24, 2:35
RE: LDView 4.2 Released - by Michael Horvath - 2016-10-24, 14:32
RE: LDView 4.2 Released - by Travis Cobbs - 2016-10-24, 17:22
RE: LDView 4.2 Released - by Michael Horvath - 2017-10-07, 20:17
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-07, 21:28
RE: LDView 4.2 Released - by Michael Horvath - 2017-10-20, 12:06
RE: LDView 4.2 Released - by Roland Melkert - 2017-10-20, 19:43
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-21, 3:32
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-21, 20:33
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-22, 4:16
RE: LDView 4.2 Released - by Michael Horvath - 2017-10-22, 20:52
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-23, 4:05
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-24, 4:34
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-24, 4:42
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-25, 5:25
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-25, 5:32
RE: LDView 4.2 Released - by Travis Cobbs - 2017-10-27, 5:46

Forum Jump:


Users browsing this thread: 11 Guest(s)