Exemplo n.º 1
0
        public GtkGL.TransformationMatrix ToTransMatrix()
        {
            if (transMatrix != null)
            {
                return(this.transMatrix);
            }

            double[] matrix = GtkGL.TransformationMatrix.Identity.Matrix;

            // Convert to radians
            double Xradians = x * 2 * Math.PI / 360.0;
            double Yradians = y * 2 * Math.PI / 360.0;
            double Zradians = z * 2 * Math.PI / 360.0;

            double ch = Math.Cos(Xradians);
            double sh = Math.Sin(Xradians);

            double ca = Math.Cos(Yradians);
            double sa = Math.Sin(Yradians);

            double cb = Math.Cos(Zradians);
            double sb = Math.Sin(Zradians);

            matrix[0 * 4 + 0] = ch * ca;
            matrix[0 * 4 + 1] = sh * sb - ch * sa * cb;
            matrix[0 * 4 + 2] = ch * sa * sb + sh * cb;
            matrix[1 * 4 + 0] = sa;
            matrix[1 * 4 + 1] = ca * cb;
            matrix[1 * 4 + 2] = -ca * sb;
            matrix[2 * 4 + 0] = -sh * ca;
            matrix[2 * 4 + 1] = sh * sa * cb + ch * sb;
            matrix[2 * 4 + 2] = -sh * sa * sb + ch * cb;

            transMatrix = new GtkGL.TransformationMatrix(matrix);

            return(transMatrix);
        }
Exemplo n.º 2
0
 void ClearCache(object o, EventArgs e)
 {
     // This should happen when the Updated handler fires
     quat = null;
     transMatrix = null;
 }
Exemplo n.º 3
0
        public GtkGL.TransformationMatrix ToTransMatrix()
        {
            if(transMatrix != null)
                return this.transMatrix;

            double[] matrix = GtkGL.TransformationMatrix.Identity.Matrix;

            // Convert to radians
            double Xradians = x * 2 * Math.PI / 360.0;
            double Yradians = y * 2 * Math.PI / 360.0;
            double Zradians = z * 2 * Math.PI / 360.0;

            double ch = Math.Cos(Xradians);
            double sh = Math.Sin(Xradians);

            double ca = Math.Cos(Yradians);
            double sa = Math.Sin(Yradians);

            double cb = Math.Cos(Zradians);
            double sb = Math.Sin(Zradians);

            matrix[0*4 + 0] = ch * ca;
            matrix[0*4 + 1] = sh*sb - ch*sa*cb;
            matrix[0*4 + 2] = ch*sa*sb + sh*cb;
            matrix[1*4 + 0] = sa;
            matrix[1*4 + 1] = ca*cb;
            matrix[1*4 + 2] = -ca*sb;
            matrix[2*4 + 0] = -sh*ca;
            matrix[2*4 + 1] =  sh*sa*cb + ch*sb;
            matrix[2*4 + 2] = -sh*sa*sb + ch*cb;

            transMatrix = new GtkGL.TransformationMatrix(matrix);

            return transMatrix;
        }
Exemplo n.º 4
0
 void ClearCache(object o, EventArgs e)
 {
     // This should happen when the Updated handler fires
     quat        = null;
     transMatrix = null;
 }