コード例 #1
0
 /// <summary>
 /// Multiplies two instances.
 /// </summary>
 /// <param name="left">The first instance.</param>
 /// <param name="right">The second instance.</param>
 /// <param name="result">A new instance containing the result of the calculation.</param>
 public static void Multiply(ref Quaterniond left, ref Quaterniond right, out Quaterniond result)
 {
     result = new Quaterniond(
         right.W * left.Xyz + left.W * right.Xyz + Vector3d.Cross(left.Xyz, right.Xyz),
         left.W * right.W - Vector3d.Dot(left.Xyz, right.Xyz));
 }
コード例 #2
0
ファイル: FormRotation.cs プロジェクト: lulzzz/ReciPro
        /// <summary>
        /// ゴニオオブジェクトを生成
        /// </summary>
        /// <param name="gl"></param>
        /// <param name="dir"></param>
        /// <param name="angle"></param>
        private void setGonio(GLControlAlpha gl, V3[] dir, double[] angle)
        {
            gl.DeleteAllObjects();

            var r   = 0.05;
            var obj = new List <GLObject>();

            var rot = dir.Select((d, i) => Matrix3D.Rot(d, angle[i])).ToArray();

            //1st
            var mat = new Material(new C4(0.8f, 0.8f, 0f, 1f));

            obj.Add(new Cone(dir[0] * 2.1, dir[0] * -0.2, r * 2, mat, DrawingMode.Surfaces));//矢
            obj.Add(new TextObject(gl.Name.Contains("ReciPro") ? "Φ" : "1st", 12, dir[0] * 2.1 + dir[0].Normalized() * 0.01, 0.05, true, mat));

            if (!checkBoxEnable2nd.Checked)                                                                                                                    //2ndが存在しない時
            {
                obj.Add(new Cylinder(dir[0] * -1.9, dir[0] * 3.8, r, mat, DrawingMode.Surfaces));                                                              //軸
                obj.Add(new Torus(new V3(0, 0, 0), rot[0] * V3.Cross(dir[0], new V3(dir[0].Z, dir[0].X, dir[0].Y)), 1.6, r * 1.5, mat, DrawingMode.Surfaces)); //トーラス
            }
            else //2ndが存在する時
            {
                obj.Add(new Cylinder(dir[0] * -1.9, dir[0] * 0.3, r, mat, DrawingMode.Surfaces));                                //軸
                obj.Add(new Cylinder(dir[0] * 1.6, dir[0] * 0.3, r, mat, DrawingMode.Surfaces));                                 //軸
                //1stトーラスの法線は、1st軸と2nd軸が直交する方向
                obj.Add(new Torus(new V3(0, 0, 0), rot[0] * V3.Cross(dir[0], dir[1]), 1.6, r * 1.5, mat, DrawingMode.Surfaces)); //トーラス

                //以下2nd
                var rot01 = rot[0] * rot[1];
                mat = new Material(new C4(0f, 0.8f, 0.8f, 1f));
                var n = rot[0] * dir[1];
                obj.Add(new Cone(n * 2.0, -n * 0.2, r * 2, mat, DrawingMode.Surfaces));//矢
                obj.Add(new TextObject(gl.Name.Contains("ReciPro") ? "Θ" : "2nd", 12, n * 2.0 + n.Normalized() * 0.01, 0.05, true, mat));

                if (!checkBoxEnable3rd.Checked)
                {
                    obj.Add(new Cylinder(n * 1.9, -n * 3.8, r, mat, DrawingMode.Surfaces));                                                                       //軸
                    obj.Add(new Torus(new V3(0, 0, 0), rot01 * V3.Cross(dir[1], new V3(dir[1].Z, dir[1].X, dir[1].Y)), 1.1, r * 1.5, mat, DrawingMode.Surfaces)); //トーラス
                }
                else
                {
                    obj.Add(new Cylinder(n * 1.9, -n * 0.8, r, mat, DrawingMode.Surfaces));                                         //軸
                    obj.Add(new Cylinder(-n * 1.9, n * 0.8, r, mat, DrawingMode.Surfaces));                                         //軸
                    //2ndトーラスの法線は、2nd軸と3rd軸が直交する方向
                    obj.Add(new Torus(new V3(0, 0, 0), rot01 * V3.Cross(dir[1], dir[2]), 1.1, r * 1.5, mat, DrawingMode.Surfaces)); //トーラス

                    //以下、3rd
                    mat = new Material(new C4(0.8f, 0f, 0.8f, 1f));
                    var rot012 = rot[0] * rot[1] * rot[2];
                    n = rot[0] * rot[1] * dir[2];
                    obj.Add(new Cylinder(n * 1.3, -n * 2.6, r, mat, DrawingMode.Surfaces));  //軸
                    obj.Add(new Cone(n * 1.45, -n * 0.2, r * 2, mat, DrawingMode.Surfaces)); //矢
                    obj.Add(new TextObject(gl.Name.Contains("ReciPro") ? "Ψ" : "3rd", 12, n * 1.45 + n.Normalized() * 0.01, 0.05, true, mat));

                    if (dir[2].Z == 0)
                    {
                        obj.Add(new Torus(new V3(0, 0, 0), rot012 * new V3(0, 0, 1), 0.6, r * 1.5, mat, DrawingMode.Surfaces));//トーラス
                    }
                    else
                    {
                        obj.Add(new Torus(new V3(0, 0, 0), rot012 * new V3(0, 1, 0), 0.6, r * 1.5, mat, DrawingMode.Surfaces));//トーラス
                    }
                }
            }


            //中央の球
            obj.AddRange(createObject(gl, dir, angle));
            gl.AddObjects(obj);
            gl.Refresh();
        }
コード例 #3
0
 public static Quaterniond Mult(Quaterniond left, Quaterniond right)
 {
     return(new Quaterniond(
                right.W * left.Xyz + left.W * right.Xyz + Vector3d.Cross(left.Xyz, right.Xyz),
                left.W * right.W - Vector3d.Dot(left.Xyz, right.Xyz)));
 }