コード例 #1
0
ファイル: Form1.cs プロジェクト: hnjm/ObsControl
        private void DrawCircle(Plotter3D p, float diameter)
        {
            float radius = diameter / 2;

            // Increasing this number will create a better approximation,
            // but will require more work to draw
            int sides = 64;

            float innerAngle = 360F / sides;

            float sideLength = (float)(radius * Math.Sin(Orientation3D.DegreesToRadians(innerAngle) / 2) * 2);

            // Save the initial position and orientation of the cursor
            Point3D       initialLocation    = p.Location;
            Orientation3D initialOrientation = p.Orientation.Clone();

            // Move to the starting point of the circle
            p.PenUp();
            p.Forward(radius - (sideLength / 2));
            p.PenDown();

            // Draw the circle
            for (int i = 0; i < sides; i++)
            {
                p.Forward(sideLength);
                p.TurnRight(innerAngle);
            }

            // Restore the position and orientation to what they were before
            // we drew the circle
            p.Location    = initialLocation;
            p.Orientation = initialOrientation;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: hnjm/ObsControl
        public void DrawSphere(Plotter3D p, float diameter)
        {
            Point3D       initialLocation    = p.Location;
            Orientation3D initialOrientation = p.Orientation.Clone();

            for (int i = 0; i < 180; i += 20)
            {
                p.PenUp();
                p.Forward(diameter / 2);

                // Rotate appropriately
                p.TurnDown(i);

                // Go back to the starting point
                p.TurnDown(180);
                p.Forward(diameter / 2);
                p.TurnDown(180);
                p.PenDown();

                DrawCircle(p, 100);

                p.Orientation = initialOrientation.Clone();
                p.Location    = initialLocation;
            }
        }
コード例 #3
0
    private static Coordinate3D Rotate(Coordinate3D c, Orientation3D o)
    {
        var p = new Point3D(c.X, c.Y, c.Z)
        {
            Orientation = o
        };

        return(new Coordinate3D(p.X, p.Y, p.Z));
    }
コード例 #4
0
ファイル: Operations.cs プロジェクト: arves100/PMD-Toolkit
 public static int DimOfDir3D(int x, int y, int z, Orientation3D ori)
 {
     if (ori == Orientation3D.Vert)
     {
         return(y);
     }
     else if (ori == Orientation3D.Horiz)
     {
         return(x);
     }
     else
     {
         return(z);
     }
 }
コード例 #5
0
        public void InitializeParticleSnow(DefaultTexturedQuadParticle cParticle)
        {
            // Position the Snow within 500 units of the emitter
            Vector3 sPosition = Emitter.PositionData.Position;

            sPosition.Y  = 200;
            sPosition.X += RandomNumber.Next(-500, 500);
            sPosition.Z += RandomNumber.Next(-500, 500);

            cParticle.Lifetime = 0.0f;

            cParticle.Position    = sPosition;
            cParticle.Size        = RandomNumber.Next(2, 5);
            cParticle.Color       = DPSFHelper.LerpColor(new Color(255, 255, 255, 50), new Color(255, 255, 255, 255), RandomNumber.NextFloat());
            cParticle.Orientation = Orientation3D.Rotate(Matrix.CreateRotationZ(RandomNumber.Between(0, MathHelper.TwoPi)), cParticle.Orientation);

            cParticle.Velocity             = new Vector3(RandomNumber.Next(-10, 3), RandomNumber.Next(-15, -5), RandomNumber.Next(-10, 10));
            cParticle.Acceleration         = Vector3.Zero;
            cParticle.RotationalVelocity.Z = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2);
        }
コード例 #6
0
        /// <summary>
        /// Obtains the translated coordinates (D) from a 3D position vector (A), camera position (C), and orentation (T).
        /// </summary>
        /// <param name="Position3D">The origional 3D position of the object in world coordinates</param>
        /// <param name="CameraPosition">The position of the camera</param>
        /// <param name="CameraOrientation">The orientation of the camera</param>
        private static Vector PerfromMatrixTranslation(Vector Position3D, Vector CameraPosition, Orientation3D CameraOrientation)
        {
            //Calculate Angles
            double Sinx = System.Math.Sin(SimMath.DegreesToRadians(-CameraOrientation[0]));
            double Siny = System.Math.Sin(SimMath.DegreesToRadians(-CameraOrientation[1]));
            double Sinz = System.Math.Sin(SimMath.DegreesToRadians(-CameraOrientation[2]));
            double Cosx = System.Math.Cos(SimMath.DegreesToRadians(-CameraOrientation[0]));
            double Cosy = System.Math.Cos(SimMath.DegreesToRadians(-CameraOrientation[1]));
            double Cosz = System.Math.Cos(SimMath.DegreesToRadians(-CameraOrientation[2]));

            //Calculate the components of (A - C)
            double X = Position3D[0] - CameraPosition[0];
            double Y = Position3D[1] - CameraPosition[1];
            double Z = Position3D[2] - CameraPosition[2];

            //Translate the coordinates
            Vector Translated = new Vector(3);

            //Dx = (Cosy * ((Sinz * Y) + (Cosz * X))) - (Siny * Z)
            Translated[0] = (Cosy * ((Sinz * Y) + (Cosz * X))) - (Siny * Z);

            //Dy = (Sinx * ((Cosy * Z) + (Siny * ((Sinz * Y) + (Cosz * X))))) + (Cosx * ((Cosz * Y) - (Sinz * X)))
            double FirstPart = (Cosy * Z) + (Siny * ((Sinz * Y) + (Cosz * X)));
            double SecondPart = (Cosz * Y) - (Sinz * X);
            Translated[1] = (Sinx * FirstPart) + (Cosx * SecondPart);

            //Dz = (Cosx * ((Cosy * Z) + (Siny * ((Sinz * Y) + (Cosz * X))))) - (Sinx * ((Cosz * Y) - (Sinz * X)))
            Translated[2] = (Cosx * FirstPart) - (Sinx * SecondPart);

            return Translated;
        }
コード例 #7
0
ファイル: Matrix3D.cs プロジェクト: gamificationvn/cstoas3
 public Vector<Vector3D> decompose(Orientation3D orientationStyle)
 {
     return null;
 }
コード例 #8
0
ファイル: Matrix3D.cs プロジェクト: gamificationvn/cstoas3
 public bool recompose(Vector<Vector3D> components, Orientation3D orientationStyle)
 {
     return true;
 }
コード例 #9
0
        public void Render(Plotter3D p)
        {
            Point3D          startLocation         = p.Location;
            Orientation3D    startOrientation      = p.Orientation.Clone();
            bool             startPenDown          = p.IsPenDown;
            AngleMeasurement startAngleMeasurement = p.AngleMeasurement;

            p.AngleMeasurement = AngleMeasurement.Degrees;

            // Move to the back edge of the domino
            p.IsPenDown = false;
            p.Forward(depth);
            p.TurnUp(90);
            p.IsPenDown = startPenDown;

            // Tilt the domino accordingly
            p.Orientation.RollLeft(90 - fallAngle);

            // Draw the back surface of the domino
            p.Forward(width);
            p.TurnLeft(90);
            p.Forward(height);
            p.TurnLeft(90);
            p.Forward(width);
            p.TurnLeft(90);
            p.Forward(height);
            p.TurnLeft(90);

            // Draw the middle bits of the domino
            p.TurnUp(90);
            p.Forward(depth);
            p.TurnDown(90);
            p.IsPenDown = false;
            p.Forward(width);
            p.TurnDown(90);
            p.IsPenDown = startPenDown;
            p.Forward(depth);
            p.TurnUp(90);
            p.TurnLeft(90);
            p.IsPenDown = false;
            p.Forward(height);
            p.TurnUp(90);
            p.IsPenDown = startPenDown;
            p.Forward(depth);
            p.TurnDown(90);
            p.TurnLeft(90);
            p.IsPenDown = false;
            p.Forward(width);
            p.TurnDown(90);
            p.IsPenDown = startPenDown;
            p.Forward(depth);
            p.IsPenDown = false;
            p.TurnUp(180);
            p.Forward(depth);
            p.TurnUp(90);
            p.Orientation.RollRight(180);
            p.IsPenDown = startPenDown;

            // Draw the front of the domino
            p.Forward(width);
            p.TurnRight(90);
            p.Forward(height);
            p.TurnRight(90);
            p.Forward(width);
            p.TurnRight(90);
            p.Forward(height);

            // Return the the start orientation and location, then advance to the back edge of the domino.
            p.IsPenDown   = false;
            p.Orientation = startOrientation;
            p.Location    = startLocation;
            p.Forward(depth);
            p.IsPenDown        = startPenDown;
            p.AngleMeasurement = startAngleMeasurement;
        }
コード例 #10
0
 ///<exclude/>
 public bool Equals(Orientation3D other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other._R.Equals(_R) && other._P.Equals(_P) && other._Y.Equals(_Y);
 }
コード例 #11
0
 public Orientation3D(Orientation3D orientation)
 {
     Forward = orientation.Forward.Clone();
     Down    = orientation.Down.Clone();
 }