コード例 #1
0
        public void Draw(CanvasContext2D ctx, Matrix3d wvp)
        {
            Vector3d a = wvp.Transform(A.Position);
            Vector3d b = wvp.Transform(B.Position);
            Vector3d c = wvp.Transform(C.Position);

            if (CheckBackface(a, b, c) != CullInside)
            {
                TrianglesCulled++;
                return;
            }

            TrianglesRendered++;

            bool rendered;
            if (factor == 1.0)
            {
                rendered = DrawTriangle(ctx, texture, (a.X + .5) * Width, (-a.Y + .5) * Height, (b.X + .5) * Width, (-b.Y + .5) * Height, (c.X + .5) * Width, (-c.Y + .5) * Height, A.Tu * 256.0, A.Tv * 256.0, B.Tu * 256.1, B.Tv * 256.0, C.Tu * 256.0, C.Tv * 256.0);
            }
            else
            {
                rendered = DrawTriangle(ctx, texture, (a.X * factor + .5) * Width, (-a.Y * factor + .5) * Height, (b.X * factor + .5) * Width, (-b.Y * factor + .5) * Height, (c.X * factor + .5) * Width, (-c.Y * factor + .5) * Height, A.Tu * 255, A.Tv * 255, B.Tu * 255, B.Tv * 255, C.Tu * 255, C.Tv * 255);
            }
            if (rendered)
            {
                TrianglesRendered++;
            }
            else
            {
                TrianglesCulled++;
            }
        }
コード例 #2
0
        public void Draw(CanvasContext2D ctx, Matrix3d wvp)
        {
            if (ctx == null)
            {
                return;
            }

            wvp.TransformTo(A.Position, ta);
            wvp.TransformTo(B.Position, tb);
            wvp.TransformTo(C.Position, tc);

            if (CheckBackface() == CullInside)
            {
                TrianglesCulled++;
                return;
            }

            //TrianglesRendered++;

            DrawTriangle(ctx, texture, ta.X, ta.Y, tb.X, tb.Y, tc.X, tc.Y, A.Tu, A.Tv, B.Tu, B.Tv, C.Tu, C.Tv);

            //if (rendered)
            //{
            //    TrianglesRendered++;
            //}
            //else
            //{
            //    TrianglesCulled++;
            //}
        }
コード例 #3
0
 public void ComputeMatrix()
 {
     Matrix = Matrix3d.Identity;
     Matrix.Multiply(Matrix3d.RotationX((float)(((Rotation)) / 180f * Math.PI)));
     Matrix.Multiply(Matrix3d.RotationZ((float)((LatCenter) / 180f * Math.PI)));
     Matrix.Multiply(Matrix3d.RotationY((float)(((360 - LngCenter)) / 180f * Math.PI)));
 }
コード例 #4
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 public static Matrix3d MultiplyMatrix(Matrix3d matrix1, Matrix3d matrix2)
 {
     if (matrix1.IsDistinguishedIdentity)
     {
         return matrix2;
     }
     if (matrix2.IsDistinguishedIdentity)
     {
         return matrix1;
     }
     return Matrix3d.Create((((matrix1._m11 * matrix2._m11) + (matrix1._m12 * matrix2._m21)) + (matrix1._m13 * matrix2._m31)) + (matrix1._m14 * matrix2._offsetX), (((matrix1._m11 * matrix2._m12) + (matrix1._m12 * matrix2._m22)) + (matrix1._m13 * matrix2._m32)) + (matrix1._m14 * matrix2._offsetY), (((matrix1._m11 * matrix2._m13) + (matrix1._m12 * matrix2._m23)) + (matrix1._m13 * matrix2._m33)) + (matrix1._m14 * matrix2._offsetZ), (((matrix1._m11 * matrix2._m14) + (matrix1._m12 * matrix2._m24)) + (matrix1._m13 * matrix2._m34)) + (matrix1._m14 * matrix2._m44), (((matrix1._m21 * matrix2._m11) + (matrix1._m22 * matrix2._m21)) + (matrix1._m23 * matrix2._m31)) + (matrix1._m24 * matrix2._offsetX), (((matrix1._m21 * matrix2._m12) + (matrix1._m22 * matrix2._m22)) + (matrix1._m23 * matrix2._m32)) + (matrix1._m24 * matrix2._offsetY), (((matrix1._m21 * matrix2._m13) + (matrix1._m22 * matrix2._m23)) + (matrix1._m23 * matrix2._m33)) + (matrix1._m24 * matrix2._offsetZ), (((matrix1._m21 * matrix2._m14) + (matrix1._m22 * matrix2._m24)) + (matrix1._m23 * matrix2._m34)) + (matrix1._m24 * matrix2._m44), (((matrix1._m31 * matrix2._m11) + (matrix1._m32 * matrix2._m21)) + (matrix1._m33 * matrix2._m31)) + (matrix1._m34 * matrix2._offsetX), (((matrix1._m31 * matrix2._m12) + (matrix1._m32 * matrix2._m22)) + (matrix1._m33 * matrix2._m32)) + (matrix1._m34 * matrix2._offsetY), (((matrix1._m31 * matrix2._m13) + (matrix1._m32 * matrix2._m23)) + (matrix1._m33 * matrix2._m33)) + (matrix1._m34 * matrix2._offsetZ), (((matrix1._m31 * matrix2._m14) + (matrix1._m32 * matrix2._m24)) + (matrix1._m33 * matrix2._m34)) + (matrix1._m34 * matrix2._m44), (((matrix1._offsetX * matrix2._m11) + (matrix1._offsetY * matrix2._m21)) + (matrix1._offsetZ * matrix2._m31)) + (matrix1._m44 * matrix2._offsetX), (((matrix1._offsetX * matrix2._m12) + (matrix1._offsetY * matrix2._m22)) + (matrix1._offsetZ * matrix2._m32)) + (matrix1._m44 * matrix2._offsetY), (((matrix1._offsetX * matrix2._m13) + (matrix1._offsetY * matrix2._m23)) + (matrix1._offsetZ * matrix2._m33)) + (matrix1._m44 * matrix2._offsetZ), (((matrix1._offsetX * matrix2._m14) + (matrix1._offsetY * matrix2._m24)) + (matrix1._offsetZ * matrix2._m34)) + (matrix1._m44 * matrix2._m44));
 }
コード例 #5
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 public static Matrix3d InvertMatrix(Matrix3d matrix3d)
 {
     Matrix3d mat = matrix3d;
     mat.Invert();
     return mat;
 }
コード例 #6
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 //public static bool operator ==(Matrix3d matrix1, Matrix3d matrix2)
 //{
 //    if (matrix1.IsDistinguishedIdentity || matrix2.IsDistinguishedIdentity)
 //    {
 //        return (matrix1.IsIdentity == matrix2.IsIdentity);
 //    }
 //    if (((((matrix1.M11 == matrix2.M11) && (matrix1.M12 == matrix2.M12)) && ((matrix1.M13 == matrix2.M13) && (matrix1.M14 == matrix2.M14))) && (((matrix1.M21 == matrix2.M21) && (matrix1.M22 == matrix2.M22)) && ((matrix1.M23 == matrix2.M23) && (matrix1.M24 == matrix2.M24)))) && ((((matrix1.M31 == matrix2.M31) && (matrix1.M32 == matrix2.M32)) && ((matrix1.M33 == matrix2.M33) && (matrix1.M34 == matrix2.M34))) && (((matrix1.OffsetX == matrix2.OffsetX) && (matrix1.OffsetY == matrix2.OffsetY)) && (matrix1.OffsetZ == matrix2.OffsetZ))))
 //    {
 //        return (matrix1.M44 == matrix2.M44);
 //    }
 //    return false;
 //}
 //public static bool operator !=(Matrix3d matrix1, Matrix3d matrix2)
 //{
 //    return !(matrix1 == matrix2);
 //}
 public static bool Equals(Matrix3d matrix1, Matrix3d matrix2)
 {
     if (matrix1.IsDistinguishedIdentity || matrix2.IsDistinguishedIdentity)
     {
         return (matrix1.IsIdentity == matrix2.IsIdentity);
     }
     if ((((matrix1.M11==(matrix2.M11) && matrix1.M12==(matrix2.M12)) && (matrix1.M13==(matrix2.M13) && matrix1.M14==(matrix2.M14))) && ((matrix1.M21==(matrix2.M21) && matrix1.M22==(matrix2.M22)) && (matrix1.M23==(matrix2.M23) && matrix1.M24==(matrix2.M24)))) && (((matrix1.M31==(matrix2.M31) && matrix1.M32==(matrix2.M32)) && (matrix1.M33==(matrix2.M33) && matrix1.M34==(matrix2.M34))) && ((matrix1.OffsetX==(matrix2.OffsetX) && matrix1.OffsetY==(matrix2.OffsetY)) && matrix1.OffsetZ==(matrix2.OffsetZ))))
     {
         return matrix1.M44==(matrix2.M44);
     }
     return false;
 }
コード例 #7
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
        public static Matrix3d Create(double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double offsetX, double offsetY, double offsetZ, double m44)
        {
            Matrix3d temp = new Matrix3d();
            temp._m11 = m11;
            temp._m12 = m12;
            temp._m13 = m13;
            temp._m14 = m14;
            temp._m21 = m21;
            temp._m22 = m22;
            temp._m23 = m23;
            temp._m24 = m24;
            temp._m31 = m31;
            temp._m32 = m32;
            temp._m33 = m33;
            temp._m34 = m34;
            temp._offsetX = offsetX;
            temp._offsetY = offsetY;
            temp._offsetZ = offsetZ;
            temp._m44 = m44;
            temp._isNotKnownToBeIdentity = true;

            return temp;
        }
コード例 #8
0
        public void SetupMatricesSpace3d(double canvasWidth, double canvasHeight)
        {
            Lighting = false;
            if (!firstTimeInit)
            {
                galacticMatrix = Matrix3d.Identity;
                // -28.9361739586894, 17.7603329867975
                galacticMatrix.Multiply(Matrix3d.RotationY(-(270-(17.7603329867975*15 )) / 180.0 * Math.PI));
                galacticMatrix.Multiply(Matrix3d.RotationX(-((-28.9361739586894)) / 180.0 * Math.PI));
                galacticMatrix.Multiply(Matrix3d.RotationZ(((31.422052860102041270114993238783)-90) / 180.0 * Math.PI));
                //galacticMatrix.Transpose();
                //galacticMatrix.Invert();
                firstTimeInit = true;
            }

            Space = true;
            RenderTriangle.CullInside = true;

            Matrix3d WorldMatrix = Matrix3d.Identity;
            if (Settings.Active.GalacticMode)
            {
                WorldMatrix.Multiply(galacticMatrix);
                WorldMatrix.Multiply(Matrix3d.RotationY(((az )) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(-((alt)) / 180.0 * Math.PI));
                double[] gPoint = Coordinates.GalactictoJ2000(az, alt);

                viewPoint = Coordinates.RADecTo3dAu(gPoint[0]/15, gPoint[1], 1.0);
                TargetCamera.Lng = this.RAtoViewLng(gPoint[0] / 15);
                TargetCamera.Lat = gPoint[1];
                ViewCamera.Lat = TargetCamera.Lat;
                ViewCamera.Lng = TargetCamera.Lng;
            }
            else
            {
                WorldMatrix.Multiply(Matrix3d.RotationY(-((ViewCamera.Lng -90 )) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(-((ViewCamera.Lat)) / 180.0 * Math.PI));
                viewPoint = Coordinates.RADecTo3dAu(RA, Dec, 1.0);
            }

            double camLocal = ((ViewCamera.Rotation /*+ 90*/));
            fovAngle = ((this.ViewCamera.Zoom) / FOVMULT) / Math.PI * 180;
            fovScale = (fovAngle / canvasHeight) * 3600;

            //Settings.Global.LocalHorizonMode = true;

            // altaz
            if (Settings.Active.LocalHorizonMode && backgroundImageset.DataSetType == ImageSetType.Sky)
            {
                Coordinates zenithAltAz = new Coordinates(0, 0);

                zenithAltAz.Az = 0;

                zenithAltAz.Alt = 0;

                Coordinates zenith = Coordinates.HorizonToEquitorial(zenithAltAz, SpaceTimeController.Location, SpaceTimeController.Now);
                //Coordinates zenith2 = Coordinates.HorizonToEquitorial(zenithAltAz, Coordinates.FromLatLng(1, 1), SpaceTimeController.Now);
                //Coordinates zenith3 = Coordinates.HorizonToEquitorial(zenithAltAz, Coordinates.FromLatLng(-1, 1), SpaceTimeController.Now);

                double raPart = -((zenith.RA - 6) / 24.0 * (Math.PI * 2));
                double decPart = -(((zenith.Dec)) / 360.0 * (Math.PI * 2));
                string raText = Coordinates.FormatDMS(zenith.RA);
                WorldMatrix = Matrix3d.RotationY(-raPart-Math.PI);
                WorldMatrix.Multiply(Matrix3d.RotationX(decPart));

                if (SpaceTimeController.Location.Lat < 0)
                {
                    WorldMatrix.Multiply(Matrix3d.RotationY(((az) / 180.0 * Math.PI)));

                    WorldMatrix.Multiply(Matrix3d.RotationX(((alt) / 180.0 * Math.PI)));
                    camLocal += Math.PI;
                }
                else
                {
                    WorldMatrix.Multiply(Matrix3d.RotationY(((-az) / 180.0 * Math.PI)));

                    WorldMatrix.Multiply(Matrix3d.RotationX(((-alt) / 180.0 * Math.PI)));
                }

                Coordinates currentRaDec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(alt, az), SpaceTimeController.Location, SpaceTimeController.Now);

                ViewCamera.Lat = TargetCamera.Lat = currentRaDec.Dec;
                ViewCamera.Lng = TargetCamera.Lng = RAtoViewLng(currentRaDec.RA);

            }
            World = WorldMatrix;
            WorldBase = WorldMatrix.Clone();
            // altaz

            double localZoomFactor = ViewCamera.Zoom;

            double FovAngle = ((localZoomFactor) / FOVMULT) / Math.PI * 180;
            CameraPosition = Vector3d.Create(0.0, 0.0, 0.0);
            // This is for distance Calculation. For space everything is the same distance, so camera target is key.

            View = Matrix3d.LookAtLH(CameraPosition, Vector3d.Create(0.0, 0.0, -1.0), Vector3d.Create(Math.Sin(camLocal), Math.Cos(camLocal), 0.0));
            ViewBase = View.Clone();

            double m_nearPlane = .1;
            nearPlane = .1f;
            Projection = Matrix3d.PerspectiveFovLH((localZoomFactor) / FOVMULT, (double)canvasWidth / (double)canvasHeight, .1, -2.0);

            SetMatrixes();

            MakeFrustum();
        }
コード例 #9
0
ファイル: SkyText.cs プロジェクト: spamarti/wwt-web-client
        public void AddGlyphPoints(List<PositionTexture> pointList, Vector2d size, Rectangle position, Rectangle uv)
        {
            PositionTexture[] points = new PositionTexture[6];

            for(int i=0; i<6;i++)
            {
                points[i] = new PositionTexture();
            }

            Vector3d left = Vector3d.Cross(center, up);
            Vector3d right = Vector3d.Cross(up, center);

            left.Normalize();
            right.Normalize();
            up.Normalize();

            Vector3d upTan = Vector3d.Cross(center, right);

            upTan.Normalize();

            if (alignment == Alignment.Center)
            {
                left.Multiply(width - position.Left * 2);
                right.Multiply(width - ((width * 2) - position.Right * 2));
            }
            else if (alignment == Alignment.Left)
            {
                left.Multiply(-position.Left * 2);
                right.Multiply(position.Right * 2);
            }

            Vector3d top = upTan.Copy();
            Vector3d bottom = Vector3d.SubtractVectors(Vector3d.Empty,upTan);

            top.Multiply(height - position.Top * 2);
            bottom.Multiply(height - ((height * 2) - position.Bottom * 2));
            Vector3d ul = center.Copy();
            ul.Add(top);
            if (sky)
            {
                ul.Add(left);
            }
            else
            {
                ul.Subtract(left);
            }
            Vector3d ur = center.Copy();
            ur.Add(top);
            if (sky)
            {
                ur.Add(right);
            }
            else
            {
                ur.Subtract(right);
            }
            Vector3d ll = center.Copy();
            if (sky)
            {
                ll.Add(left);
            }
            else
            {
                ll.Subtract(left);
            }

            ll.Add(bottom);

            Vector3d lr = center.Copy();
            if (sky)
            {
                lr.Add(right);
            }
            else
            {
                lr.Subtract(right);
            }
            lr.Add(bottom);

            points[0].Position = ul.Copy();
            points[0].Tu = uv.Left;
            points[0].Tv = uv.Top;
               //     points[0].Color = Color;

            points[2].Tu = uv.Left;
            points[2].Tv = uv.Bottom;
            points[2].Position = ll.Copy();
              //      points[2].Color = Color;

            points[1].Tu = uv.Right;
            points[1].Tv = uv.Top;
            points[1].Position = ur.Copy();
              //      points[1].Color = Color;

            points[3].Tu = uv.Right;
            points[3].Tv = uv.Bottom;
            points[3].Position = lr.Copy();
              //      points[3].Color = Color;

            points[5].Tu = uv.Right;
            points[5].Tv = uv.Top;
            points[5].Position = ur.Copy();
               //     points[5].Color = Color;

            points[4].Tu = uv.Left;
            points[4].Tv = uv.Bottom;
            points[4].Position = ll.Copy();
               //     points[4].Color = Color;

            if (Rotation != 0 || Tilt != 0 || Bank != 0)
            {
                if (!matInit)
                {
                    Matrix3d lookAt = Matrix3d.LookAtLH(center, new Vector3d(), up);
                    Matrix3d lookAtInv = lookAt.Clone();
                    lookAtInv.Invert();

                    rtbMat =  Matrix3d.MultiplyMatrix(Matrix3d.MultiplyMatrix(Matrix3d.MultiplyMatrix( Matrix3d.MultiplyMatrix(lookAt, Matrix3d.RotationZ(-Rotation / 180 * Math.PI)),  Matrix3d.RotationX(-Tilt / 180 * Math.PI)),  Matrix3d.RotationY(-Bank / 180 * Math.PI)), lookAtInv);
                    //todo make this true after debug
                    matInit = true;
                }
                for (int i = 0; i < 6; i++)
                {
                    points[i].Position = Vector3d.TransformCoordinate(points[i].Position, rtbMat);
                }
            }

            pointList.AddRange(points);
        }
コード例 #10
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 internal void Multiply(Matrix3d mat)
 {
     Set(Matrix3d.MultiplyMatrix(this, mat));
 }
コード例 #11
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
        public void Transpose()
        {
            Matrix3d that = new Matrix3d();
            that.Set(this);

            this._m12 = that._m21;
            this._m13 = that._m31;
            this._m14 = that._offsetX;
            this._m23 = that._m32;
            this._m24 = that._offsetY;
            this._m34 = that._offsetZ;
            this._m21 = that._m12;
            this._m31 = that._m13;
            this._offsetX = that._m14;
            this._m32 = that._m23;
            this._offsetY = that._m24;
            this._offsetZ = that._m34;
        }
コード例 #12
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 public void Set(Matrix3d mat)
 {
     this._m11 = mat._m11;
     this._m12 = mat._m12;
     this._m13 = mat._m13;
     this._m14 = mat._m14;
     this._m21 = mat._m21;
     this._m22 = mat._m22;
     this._m23 = mat._m23;
     this._m24 = mat._m24;
     this._m31 = mat._m31;
     this._m32 = mat._m32;
     this._m33 = mat._m33;
     this._m34 = mat._m34;
     this._offsetX = mat._offsetX;
     this._offsetY = mat._offsetY;
     this._offsetZ = mat._offsetZ;
     this._m44 = mat._m44;
     this._isNotKnownToBeIdentity = true;
 }
コード例 #13
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 public void Prepend(Matrix3d matrix)
 {
     Set(MultiplyMatrix(matrix,this));
 }
コード例 #14
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 public Matrix3d Clone()
 {
     Matrix3d tmp = new Matrix3d();
     tmp.Set(this);
     return tmp;
 }
コード例 #15
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 public void Append(Matrix3d matrix)
 {
     this.Multiply(matrix);
 }
コード例 #16
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 internal static Vector3d TransformCoordinate(Vector3d vector3d, Matrix3d mat)
 {
     return mat.Transform(vector3d);
 }
コード例 #17
0
ファイル: Planets.cs プロジェクト: spamarti/wwt-web-client
        public static void UpdateOrbits(int planetCenter)
        {
            try
            {
                //if (!downloadedPlanets)
                //{
                //    Wtml.GetWtmlFile("", PlanetsReady);
                //}

                obliquity = Coordinates.MeanObliquityOfEcliptic(SpaceTimeController.JNow) * RC;
                if (planetCenter != lastPlanetCenterID)
                {
                    orbits = null;
                }
                lastPlanetCenterID = planetCenter;
                if (orbits == null)
                {
                    if (planetCenter < 0)
                    {
                        eclipticTilt = Matrix3d.Identity;
                    }
                    else
                    {
                        eclipticTilt = Matrix3d.Identity;
                        eclipticTilt = Matrix3d.RotationX((float)obliquity);
                    }
                    if (planetOrbitalYears == null)
                    {
                        planetOrbitalYears = new double[20];
                        planetOrbitalYears[0] = 1;
                        planetOrbitalYears[1] = .241;
                        planetOrbitalYears[2] = .615;
                        planetOrbitalYears[3] = 1.881;
                        planetOrbitalYears[4] = 11.87;
                        planetOrbitalYears[5] = 29.45;
                        planetOrbitalYears[6] = 84.07;
                        planetOrbitalYears[7] = 164.9;
                        planetOrbitalYears[8] = 248.1;
                        planetOrbitalYears[9] = 27.3 / 365.25;
                        planetOrbitalYears[10] = 16.6890184 / 365.25;
                        planetOrbitalYears[11] = 3.551181 / 365.25;
                        planetOrbitalYears[12] = 7.15455296 / 365.25;
                        planetOrbitalYears[13] = 16.6890184 / 365.25;
                        planetOrbitalYears[19] = 1;

                    }
                    if (!ReadOrbits())
                    {
                        orbits = new Vector3d[20][];

                        for (int i = 1; i < 20; i++)
                        {
                            orbits[i] = new Vector3d[orbitalSampleRate];

                            if (i < 9 || i == 19)
                            {
                                for (int j = 0; j < orbitalSampleRate; j++)
                                {
                                    int centerId = planetCenter;
                                    double now = jNow + ((planetOrbitalYears[i] * 365.25 / (orbitalSampleRate)) * (double)(j - (orbitalSampleRate / 2)));
                                    Vector3d center = new Vector3d();

                                    if (i == (int)SolarSystemObjects.Moon)
                                    {
                                        centerId = -1;
                                    }
                                    else if (i > 9 && i < 14)
                                    {
                                        centerId = (int)SolarSystemObjects.Jupiter;
                                    }

                                    if (centerId > -1)
                                    {
                                        AstroRaDec centerRaDec = AstroCalc.GetPlanet(now, (EO)centerId, 0, 0, -6378149);
                                        center = Coordinates.RADecTo3dAu(centerRaDec.RA, centerRaDec.Dec, centerRaDec.Distance);
                                    }

                                    if (i != 19)
                                    {
                                        AstroRaDec planetRaDec = AstroCalc.GetPlanet(now, (EO)i, 0, 0, -6378149);
                                        // todo move to double precition for less trucation
                                        orbits[i][ j] = (Vector3d)Coordinates.RADecTo3dAu(planetRaDec.RA, planetRaDec.Dec, planetRaDec.Distance);
                                        orbits[i][j].Subtract( (Vector3d)center);
                                    }
                                    else
                                    {
                                        orbits[i][j] = Vector3d.Create(-center.X, -center.Y, -center.Z);
                                    }

                                    // todo is the tilt right?
                                    //if (i != (int)SolarSystemObjects.Moon && !((i > 9 && i < 14)))
                                    {
                                        orbits[i][j].RotateX(obliquity);
                                    }
                                }
                                orbits[i][ orbitalSampleRate - 1] = orbits[i][0];
                            }
                        }
                        DumpOrbitsFile();
                    }
                }
            }
            finally
            {
            //                OrbitsMutex.ReleaseMutex();
            }
        }
コード例 #18
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 internal void TransformByMatrics(Matrix3d lookAtAdjust)
 {
     Vector3d temp = lookAtAdjust.Transform(this);
     this.X = temp.X;
     this.Y = temp.Y;
     this.Z = temp.Z;
 }
コード例 #19
0
 private void ComputeMatrix()
 {
     matrixComputed = true;
     matrix = Matrix3d.Identity;
     matrix.Multiply(Matrix3d.RotationX((((Rotation)) / 180f * Math.PI)));
     matrix.Multiply(Matrix3d.RotationZ(((CenterY) / 180f * Math.PI)));
     matrix.Multiply(Matrix3d.RotationY((((360 - CenterX) + 180) / 180f * Math.PI)));
 }
コード例 #20
0
ファイル: Double3D.cs プロジェクト: spamarti/wwt-web-client
 static Matrix3d()
 {
     s_identity = CreateIdentity();
 }
コード例 #21
0
 public static Vector3d RADecTo3dMat(double ra, double dec, Matrix3d mat)
 {
     return Vector3d.TransformCoordinate(Vector3d.Create((Math.Cos(ra * RCRA) * Math.Cos(dec * RC) * radius), (Math.Sin(dec * RC) * radius), (Math.Sin(ra * RCRA) * Math.Cos(dec * RC) * radius)), mat);
 }
コード例 #22
0
        public void MakeFrustum()
        {
            WV = Matrix3d.MultiplyMatrix(World, View);

            Matrix3d viewProjection =  Matrix3d.MultiplyMatrix(WV, Projection);

            WVP = viewProjection.Clone();

            Matrix3d inverseWorld = World.Clone();
            inverseWorld.Invert();

            // Left plane
            frustum[0].A = viewProjection.M14 + viewProjection.M11;
            frustum[0].B = viewProjection.M24 + viewProjection.M21;
            frustum[0].C = viewProjection.M34 + viewProjection.M31;
            frustum[0].D = viewProjection.M44 + viewProjection.M41;

            // Right plane
            frustum[1].A = viewProjection.M14 - viewProjection.M11;
            frustum[1].B = viewProjection.M24 - viewProjection.M21;
            frustum[1].C = viewProjection.M34 - viewProjection.M31;
            frustum[1].D = viewProjection.M44 - viewProjection.M41;

            // Top plane
            frustum[2].A = viewProjection.M14 - viewProjection.M12;
            frustum[2].B = viewProjection.M24 - viewProjection.M22;
            frustum[2].C = viewProjection.M34 - viewProjection.M32;
            frustum[2].D = viewProjection.M44 - viewProjection.M42;

            // Bottom plane
            frustum[3].A = viewProjection.M14 + viewProjection.M12;
            frustum[3].B = viewProjection.M24 + viewProjection.M22;
            frustum[3].C = viewProjection.M34 + viewProjection.M32;
            frustum[3].D = viewProjection.M44 + viewProjection.M42;

            // Near plane
            frustum[4].A = viewProjection.M13;
            frustum[4].B = viewProjection.M23;
            frustum[4].C = viewProjection.M33;
            frustum[4].D = viewProjection.M43;

            // Far plane
            frustum[5].A = viewProjection.M14 - viewProjection.M13;
            frustum[5].B = viewProjection.M24 - viewProjection.M23;
            frustum[5].C = viewProjection.M34 - viewProjection.M33;
            frustum[5].D = viewProjection.M44 - viewProjection.M43;

            // Normalize planes
            for (int i = 0; i < 6; i++)
            {
                frustum[i].Normalize();

            }
            frustumDirty = false;

            WVP.Scale( Vector3d.Create(Width/2, -Height/2, 1));
            WVP.Translate(Vector3d.Create(Width/2, Height/2, 0));
            SetMatrixes();
        }