Beispiel #1
0
        //!Apply the cross-product of this and a vector
        public GLVector4d cross(GLVector4d gv)
        {
            double[] temp = new double[] { x, y, z, w };

            x = temp[1] * gv.z - temp[2] * gv.y;
            y = temp[2] * gv.w - temp[3] * gv.z;
            z = temp[3] * gv.x - temp[0] * gv.w;
            w = temp[0] * gv.y - temp[1] * gv.x;

            return(this);
        }
Beispiel #2
0
        //!Get the matrix vector dot product, used to transform vertecies
        public static GLVector4d operator*(GLMatrix4d mat, GLVector4d vec)
        {
            GLVector4d ret = new GLVector4d();

            for (byte j = 0; j < 4; ++j)
            {
                ret.val[j] = vec.x * mat[j]
                             + vec.y * mat[j + 4]
                             + vec.z * mat[j + 8]
                             + vec.w * mat[j + 12];
            }
            return(ret);
        }
 //!Get the matrix vector dot product, used to transform vertecies
 public static GLVector4d operator* ( GLMatrix4d mat, GLVector4d vec)
 {
     GLVector4d ret = new GLVector4d();
     for(byte j = 0; j < 4; ++j)
     {
         ret.val[j] = vec.x*mat[j]
                    + vec.y*mat[j+4]
                    + vec.z*mat[j+8]
                    + vec.w*mat[j+12];
     }
     return ret;
 }
 //!Get the vector projection of this and a vector
 public GLVector4d vectorProjection( GLVector4d vin)
 {
     return this * dot(vin);
 }
 //!Get the projection of this and a vector
 public double projection( GLVector4d vin)
 {
     return dot(vin);
 }
 //!Get the orthogonal projection of this and a vector
 public GLVector4d orthogonalProjection( GLVector4d vin)
 {
     return vin - vectorProjection(vin);
 }
 //!Get the cross-product of this and a vector
 public GLVector4d getCross( GLVector4d gv)
 {
     return new GLVector4d(y*gv.z-z*gv.y,z*gv.w-w*gv.z,w*gv.x-x*gv.w,x*gv.y-y*gv.x);
 }
 //!Get the dot product of this and a vector
 public double dot( GLVector4d gv)
 {
     return x*gv.x + y*gv.y + z * gv.z + w * gv.w;
 }
        //!Apply the cross-product of this and a vector
        public GLVector4d cross( GLVector4d gv)
        {
            double[] temp = new double[]{ x, y, z, w };

            x = temp[1] * gv.z - temp[2] * gv.y;
            y = temp[2] * gv.w - temp[3] * gv.z;
            z = temp[3] * gv.x - temp[0] * gv.w;
            w = temp[0] * gv.y - temp[1] * gv.x;

            return this;
        }
 //!Copy a vector
 public GLVector4d( GLVector4d gv)
 {
     Buffer.BlockCopy( gv.val, 0, val, 0, Buffer.ByteLength( gv.val ) );
 }
Beispiel #11
0
 //!Get the cross-product of this and a vector
 public GLVector4d getCross(GLVector4d gv)
 {
     return(new GLVector4d(y * gv.z - z * gv.y, z * gv.w - w * gv.z, w * gv.x - x * gv.w, x * gv.y - y * gv.x));
 }
Beispiel #12
0
 //!Get the vector projection of this and a vector
 public GLVector4d vectorProjection(GLVector4d vin)
 {
     return(this * dot(vin));
 }
Beispiel #13
0
 //!Get the orthogonal projection of this and a vector
 public GLVector4d orthogonalProjection(GLVector4d vin)
 {
     return(vin - vectorProjection(vin));
 }
Beispiel #14
0
 //!Get the projection of this and a vector
 public double projection(GLVector4d vin)
 {
     return(dot(vin));
 }
Beispiel #15
0
 //!Get the dot product of this and a vector
 public double dot(GLVector4d gv)
 {
     return(x * gv.x + y * gv.y + z * gv.z + w * gv.w);
 }
Beispiel #16
0
 //!Copy a vector
 public GLVector4d(GLVector4d gv)
 {
     Buffer.BlockCopy(gv.val, 0, val, 0, Buffer.ByteLength(gv.val));
 }