/// <summary> /// Gets the matrix. /// </summary> /// <returns>The matrix.</returns> /// <param name="fixedAngles">Fixed angles. Degree value </param> static public Matrix4x4 GetMatrix(Vector3 fixedAngles) { IvQuat ivQ = new IvQuat(); ivQ.Set(fixedAngles.z * Mathf.Deg2Rad, fixedAngles.y * Mathf.Deg2Rad, fixedAngles.x * Mathf.Deg2Rad); return(IvQuat.GetMatrix(ivQ)); }
static public Quaternion GetQuaternion(TRSParser parser) { Quaternion u_q = Quaternion.identity; foreach (TRSParser.Sentences sts in parser) { if (0 == sts.Count) { continue; } switch (sts.kind) { case TRSParser.Sentences.eKind.Quaternion: { ///1. //u_q.eulerAngles = sts[0].xyz; ///2. IvQuat iv_q = new IvQuat(); Vector3 v3Rad = sts [0].xyz * Mathf.Deg2Rad; iv_q.Set(v3Rad.z, v3Rad.y, v3Rad.x); u_q.w = iv_q.w; u_q.x = iv_q.x; u_q.y = iv_q.y; u_q.z = iv_q.z; } break; } } return(u_q); }
static public Matrix4x4 ParsingMatrix(TRSParser parser, string order) { parser.Parsing(order); Matrix4x4 trs = Matrix4x4.identity; foreach (TRSParser.Sentences sts in parser) { if (0 == sts.Count) { continue; } switch (sts.kind) { case TRSParser.Sentences.eKind.Translate: { trs = trs * TRSHelper.GetTranslate(sts [0].xyz); } break; case TRSParser.Sentences.eKind.Rotate: { if (TRSParser.Command.eKind.X == sts [0].kind) { trs = trs * TRSHelper.GetRotateX(sts [0].degree); } if (TRSParser.Command.eKind.Y == sts [0].kind) { trs = trs * TRSHelper.GetRotateY(sts [0].degree); } if (TRSParser.Command.eKind.Z == sts [0].kind) { trs = trs * TRSHelper.GetRotateZ(sts [0].degree); } } break; case TRSParser.Sentences.eKind.Quaternion: { IvQuat q = new IvQuat(); Vector3 v3Rad = sts [0].xyz * Mathf.Deg2Rad; q.Set(v3Rad.z, v3Rad.y, v3Rad.x); Matrix4x4 m = q.GetMatrix(); trs = trs * m; //chamto test - print fixedAngles of IvQuat Vector3 angles = IvQuat.GetFixedAnglesFrom(ref m); angles *= Mathf.Rad2Deg; DebugWide.LogRed("1: IvQuat angles : " + angles + "\n"); //chamto test } break; case TRSParser.Sentences.eKind.Scale: trs = trs * TRSHelper.GetScale(sts [0].xyz); break; } } return(trs); }
void Start() { Matrix4x4 mrx = Matrix4x4.identity; Matrix4x4 mry = Matrix4x4.identity; Matrix4x4 mrz = Matrix4x4.identity; Matrix4x4 mt = Matrix4x4.identity; Matrix4x4 r = Matrix4x4.zero; mrx = TRSHelper.GetRotateX(45f); mry = TRSHelper.GetRotateY(45f); mrz = TRSHelper.GetRotateY(0f); mt = TRSHelper.GetTranslate(new Vector3(0, 0, 0)); //r = mrx * mry * mrz * mt; r = mt * mrx * mry * mrz; //r = mrx * mry * mrz; IvQuat quat = new IvQuat(); quat.Set(0f, 45f, 45f); r = quat.GetMatrix(); //this.ApplyMatrixToGroupPosition (_testAxis, r); //this.ApplyMatrixToGroupPosition (_testAxis, r); //_testTarget.position = r.MultiplyPoint (_testTarget.position); //_testTarget.position = mt.MultiplyPoint (_testTarget.position); //------------------------------------------------------------ // float 비트 배열 분석 //------------------------------------------------------------ // bool bigIndian = true; // DebugWide.LogBlue(ML.Util.ToBit(10.25f) + ": 10.25f"); // DebugWide.LogBlue(ML.Util.ToBit(1f,bigIndian) + ": 1f "); // DebugWide.LogBlue(ML.Util.ToBit(-1f,bigIndian) + ": -1f "); // DebugWide.LogBlue(ML.Util.ToBit(2f,bigIndian) + ": 2f "); // DebugWide.LogBlue(ML.Util.ToBit(-2f,bigIndian) + ": -2f "); // DebugWide.LogBlue(ML.Util.ToBit(3f,bigIndian) + ": 3f "); // DebugWide.LogBlue(ML.Util.ToBit(-3f,bigIndian) + ": -3f "); // DebugWide.LogBlue(ML.Util.ToBit(4f,bigIndian) + ": 4f "); // DebugWide.LogBlue(ML.Util.ToBit(-4f,bigIndian) + ": -4f "); // DebugWide.LogBlue(ML.Util.ToBit(5f,bigIndian) + ": 5f "); // DebugWide.LogBlue(ML.Util.ToBit(-5f,bigIndian) + ": -5f "); // DebugWide.LogBlue(ML.Util.ToBit(6f,bigIndian) + ": 6f "); // DebugWide.LogBlue(ML.Util.ToBit(-6f,bigIndian) + ": -6f "); // DebugWide.LogBlue(ML.Util.ToBit(float.NaN) + ": Nan"); // DebugWide.LogBlue(ML.Util.ToBit(float.Epsilon) + ": Epsilon " + float.Epsilon); // DebugWide.LogBlue(ML.Util.ToBit(float.PositiveInfinity) + ": PositiveInfinity"); // DebugWide.LogBlue(ML.Util.ToBit(float.NegativeInfinity) + ": NegativeInfinity"); // // // float a = 1.00000011920929f; //1 + 1.0 * 1/(2^23) // float b = 1.0f - a; // DebugWide.LogBlue (Mathf.Log (8388608, 2)); //Log2^8388608 = 23 // // DebugWide.LogBlue(ML.Util.ToBit(a) + ": a1 : " + a + " sqrt : " + Mathf.Sqrt(b)); // //a = 1.00000011111f; // //a = 1.0000001f; // //a = 1.000001f; // // if(float.Epsilon < Mathf.Abs(b)) // DebugWide.LogBlue(ML.Util.ToBit(b) + ": a2 : " + a); // // DebugWide.LogBlue(ML.Util.ToBit(b) + ": b3 : " + b); this.SavePosition(_testAxis); }