Ejemplo n.º 1
0
///////////////////////////////////////////////////////////////////////////////
// Creates a 3x3 rotation matrix, takes radians NOT degrees
void m3dRotationMatrix33(M3DMatrix33f m, float angle, float x, float y, float z)
	{
	
	float mag, s, c;
	float xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c;

	s = float(sin(angle));
	c = float(cos(angle));

	mag = float(sqrt( x*x + y*y + z*z ));

	// Identity matrix
	if (mag == 0.0f) {
		m3dLoadIdentity33(m);
		return;
	}

	// Rotation matrix is normalized
	x /= mag;
	y /= mag;
	z /= mag;



	xx = x * x;
	yy = y * y;
	zz = z * z;
	xy = x * y;
	yz = y * z;
	zx = z * x;
	xs = x * s;
	ys = y * s;
	zs = z * s;
	one_c = 1.0f - c;

	M33(0,0) = (one_c * xx) + c;
	M33(0,1) = (one_c * xy) - zs;
	M33(0,2) = (one_c * zx) + ys;

	M33(1,0) = (one_c * xy) + zs;
	M33(1,1) = (one_c * yy) + c;
	M33(1,2) = (one_c * yz) - xs;

	M33(2,0) = (one_c * zx) - ys;
	M33(2,1) = (one_c * yz) + xs;
	M33(2,2) = (one_c * zz) + c;
	}
Ejemplo n.º 2
0
void
DOMMatrixReadOnly::Stringify(nsAString& aResult)
{
  nsAutoString matrixStr;
  if (mMatrix3D) {
    matrixStr.AppendPrintf("matrix3d(%g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g, %g)",
      M11(), M12(), M13(), M14(),
      M21(), M22(), M23(), M24(),
      M31(), M32(), M33(), M34(),
      M41(), M42(), M43(), M44());
  } else {
    matrixStr.AppendPrintf("matrix(%g, %g, %g, %g, %g, %g)", A(), B(), C(), D(), E(), F());
  }

  aResult = matrixStr;
}
Ejemplo n.º 3
0
void
DOMMatrixReadOnly::Stringify(nsAString& aResult)
{
  nsAutoString matrixStr;
  if (mMatrix3D) {
    // We can't use AppendPrintf here, because it does locale-specific
    // formatting of floating-point values.
    matrixStr.AssignLiteral("matrix3d(");
    AppendFloat(matrixStr, M11()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M12()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M13()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M14()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M21()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M22()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M23()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M24()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M31()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M32()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M33()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M34()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M41()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M42()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M43()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, M44());
    matrixStr.AppendLiteral(")");
  } else {
    // We can't use AppendPrintf here, because it does locale-specific
    // formatting of floating-point values.
    matrixStr.AssignLiteral("matrix(");
    AppendFloat(matrixStr, A()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, B()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, C()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, D()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, E()); matrixStr.AppendLiteral(", ");
    AppendFloat(matrixStr, F());
    matrixStr.AppendLiteral(")");
  }

  aResult = matrixStr;
}