chetto1983 / jsc3d

Automatically exported from code.google.com/p/jsc3d
0 stars 0 forks source link

Get current rotation #82

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
How to get current rotation (x,y,z). I want this to set InitRotation of next 
model (InitRotationX,InitRotationY,InitRotationZ) ?

Original issue reported on code.google.com by fabien...@gmail.com on 22 Jul 2014 at 2:30

GoogleCodeExporter commented 8 years ago
The function is here. You can add it into jsc3d.js:

/**
 * Get current rotation angles around X, Y and Z axis.
 */
JSC3D.Viewer.prototype.getRotationAngles = function() {
    var angles = [
        Math.atan2(this.rotMatrix.m21, this.rotMatrix.m22) * 180 / Math.PI, // rotX
        Math.asin(-this.rotMatrix.m20) * 180 / Math.PI,                     // rotY
        Math.atan2(this.rotMatrix.m10, this.rotMatrix.m00) * 180 / Math.PI  // rotZ
    ];

    if(angles[0] < 0)
      angles[0] += 360;
    if(angles[1] < 0)
      angles[1] += 360;
    if(angles[2] < 0)
      angles[2] += 360;

    return angles;
};

whose return value is a triple containing current rotation angles around X, Y 
and Z axis.  This was implemented in an experimental branched edition but not 
merged to the main edition.

Original comment by Humu2...@gmail.com on 22 Jul 2014 at 11:04

GoogleCodeExporter commented 8 years ago
Thank you. I will try this.

Original comment by fabien...@gmail.com on 23 Jul 2014 at 3:02

GoogleCodeExporter commented 8 years ago
It gives wrong values

Original comment by webdevel...@gmail.com on 25 Feb 2015 at 11:59