コード例 #1
0
        public static sg_Vector3 getNormal(sg_Vector3 p1, sg_Vector3 p2, sg_Vector3 p3)
        {
            sg_Vector3 v   = p3 - p1;
            sg_Vector3 ret = v.crossMul(p2 - p1);

            ret.Normalize();
            return(ret);
        }
コード例 #2
0
        public sg_Transformation(sg_Vector3 n1, sg_Vector3 n2, sg_Vector3 cenPt)
        {
            sg_Vector3 newZ = new sg_Vector3(n1);
            sg_Vector3 newY = newZ.crossMul(n2);
            sg_Vector3 newX = newY.crossMul(newZ);

            newX.Normalize();
            newY.Normalize();
            newZ.Normalize();

            _r[0, 0] = newX.x; _r[0, 1] = newY.x; _r[0, 2] = newZ.x;
            _r[1, 0] = newX.y; _r[1, 1] = newY.y; _r[1, 2] = newZ.y;
            _r[2, 0] = newX.z; _r[2, 1] = newY.z; _r[2, 2] = newZ.z;

            _t[0] = cenPt.x; _t[1] = cenPt.y; _t[2] = cenPt.z;
        }
コード例 #3
0
//      public sg_Transformation(sg_Vector3 v0,  sg_Vector3 v1,  sg_Vector3 v2)
//      {
//          sg_Vector3 W1 = v1 - v0;
//          sg_Vector3 W3 = W1.crossMul(v2 - v0);
//          sg_Vector3 W2 = W3.crossMul(W1);
//
//          W1.Normalize();
//          W2.Normalize();
//          W3.Normalize();
//
//          _r[0,0] = W1.x; _r[0,1] = W2.x; _r[0,2] = W3.x;
//          _r[1,0] = W1.y; _r[1,1] = W2.y; _r[1,2] = W3.y;
//          _r[2,0] = W1.z; _r[2,1] = W2.z; _r[2,2] = W3.z;
//
//          _t[0] = v0.x; _t[1] = v0.y; _t[2] = v0.z;
//
//      }
//
        public sg_Transformation(sg_Vector3 n, sg_Vector3 cenPt)
        {
            sg_Vector3 newZ = new sg_Vector3(n);
            sg_Vector3 newX = new sg_Vector3(90, n.getDip() - 90);
            sg_Vector3 newY = newZ.crossMul(newX);

            newX.Normalize();
            newY.Normalize();
            newZ.Normalize();

            _r[0, 0] = newX.x; _r[0, 1] = newY.x; _r[0, 2] = newZ.x;
            _r[1, 0] = newX.y; _r[1, 1] = newY.y; _r[1, 2] = newZ.y;
            _r[2, 0] = newX.z; _r[2, 1] = newY.z; _r[2, 2] = newZ.z;

            _t[0] = cenPt.x; _t[1] = cenPt.y; _t[2] = cenPt.z;
        }