setFromEuler method

Quat setFromEuler(
  1. double x,
  2. double y,
  3. double z
)

Set Quant using Euler equation

Implementation

Quat setFromEuler(double x, double y, double z){
  var c1 = math.cos( x * 0.5 );
  var c2 = math.cos( y * 0.5 );
  var c3 = math.cos( z * 0.5 );
  var s1 = math.sin( x * 0.5 );
  var s2 = math.sin( y * 0.5 );
  var s3 = math.sin( z * 0.5 );

  // XYZ
  this.x = s1 * c2 * c3 + c1 * s2 * s3;
  this.y = c1 * s2 * c3 - s1 * c2 * s3;
  this.z = c1 * c2 * s3 + s1 * s2 * c3;
  w = c1 * c2 * c3 - s1 * s2 * s3;

  return this;
}