Пример #1
0
        /// <summary>
        /// Instantiates a new Orientation object.
        /// </summary>
        public Orientation3D()
        {
            forwardVector = new Vector3D(1, 0, 0);
            downVector = new Vector3D(0, 0, 1);

            angleMeasurement = AngleMeasurement.Degrees;
        }
Пример #2
0
        public static void Render(RenderManager.CameraInfo cameraInfo, AngleMeasurement angle)
        {
            if (angle.HideOverlay)
            {
                return;
            }

            var renderManager = RenderManager.instance;

            var centreAngle = Vector3.Angle(Vector3.right, angle.AngleNormal);

            if (Vector3.Cross(Vector3.right, angle.AngleNormal).y > 0f)
            {
                centreAngle = -centreAngle;
            }

            var arcs = BezierUtil.CreateArc(angle.Position, GetAngleDistance(angle.Flags),
                                            centreAngle - angle.AngleSize * .5f,
                                            centreAngle + angle.AngleSize * .5f);

            for (var i = 0; i < arcs.Count; i++)
            {
                var isFirst = i == 0;
                var isLast  = i == arcs.Count - 1;

                renderManager.OverlayEffect.DrawBezier(cameraInfo, GetAngleColor(angle.Flags), arcs[i], .7f, 0f, 0f,
                                                       angle.Position.y - 20f,
                                                       angle.Position.y + 20f, false, true);
            }
        }
Пример #3
0
        /// <summary>
        /// Creates a deep copy of an existing orientation object.
        /// </summary>
        /// <param name="source">The source orientation for the copy.</param>
        private Orientation3D(Orientation3D source)
        {
            forwardVector = source.ForwardVector;
            downVector = source.downVector;

            angleMeasurement = source.angleMeasurement;
        }
Пример #4
0
        public void Angle_AngleMeasurement_DefaultsToDegrees()
        {
            const AngleMeasurement expected = AngleMeasurement.Degrees;

            var result = InstantiateNewCoordinate().AngleMeasurement;

            Assert.Equal(expected, result);
        }
Пример #5
0
        public void Angle_CanInstantiateWithValueAndMeasurement(double value)
        {
            var expectedValue = value;
            const AngleMeasurement angleMeasurement = AngleMeasurement.Radians;

            var sut               = new Angle(value, AngleMeasurement.Radians);
            var resultValue       = sut.Value;
            var resultMeasurement = sut.AngleMeasurement;

            Assert.Equal(expectedValue, resultValue);
            Assert.Equal(angleMeasurement, resultMeasurement);
        }
Пример #6
0
        public double GetArgument(AngleMeasurement m)
        {
            switch (m)
            {
            case AngleMeasurement.Degrees:
                return(getArg() * 180.0 / Math.PI);

            case AngleMeasurement.Radians:
                return(getArg());

            default:
                throw new ArgumentOutOfRangeException("Invalid angle measurement");
            }
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionParameters"/> class.
 /// </summary>
 /// <param name="angleMeasurement">The angle measurement.</param>
 /// <param name="variables">The collection of variables' values.</param>
 /// <param name="functions">The collection of user functions.</param>
 public ExpressionParameters(AngleMeasurement angleMeasurement, ParameterCollection variables, FunctionCollection functions)
 {
     this.AngleMeasurement = angleMeasurement;
     this.Variables        = variables;
     this.Functions        = functions;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionParameters"/> class.
 /// </summary>
 /// <param name="angleMeasurement">The angle measurement.</param>
 /// <param name="functions">The collection of user functions.</param>
 public ExpressionParameters(AngleMeasurement angleMeasurement, FunctionCollection functions)
     : this(angleMeasurement, new ParameterCollection(), functions)
 {
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionParameters"/> class.
 /// </summary>
 /// <param name="angleMeasurement">The angle measurement.</param>
 /// <param name="variables">The collection of variables' values.</param>
 public ExpressionParameters(AngleMeasurement angleMeasurement, ParameterCollection variables)
     : this(angleMeasurement, variables, new FunctionCollection())
 {
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionParameters"/> class.
 /// </summary>
 /// <param name="angleMeasuremnt">The angle measuremnt.</param>
 public ExpressionParameters(AngleMeasurement angleMeasuremnt)
     : this(angleMeasuremnt, new ParameterCollection(), new FunctionCollection())
 {
 }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionParameters"/> class.
 /// </summary>
 /// <param name="angleMeasuremnt">The angle measuremnt.</param>
 /// <param name="functions">The collection of user functions.</param>
 public ExpressionParameters(AngleMeasurement angleMeasuremnt, FunctionCollection functions)
     : this(angleMeasuremnt, new ParameterCollection(), functions)
 {
 }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionParameters"/> class.
 /// </summary>
 /// <param name="angleMeasuremnt">The angle measuremnt.</param>
 /// <param name="parameters">The collection of variables' values.</param>
 public ExpressionParameters(AngleMeasurement angleMeasuremnt, ParameterCollection parameters)
     : this(angleMeasuremnt, parameters, new FunctionCollection())
 {
 }
Пример #13
0
        public static Complex ComplexNumberFromMagnitudeAndPhase(double r, double phi, AngleMeasurement m)
        {
            switch (m)
            {
            case AngleMeasurement.Degrees:
                return(ComplexNumberFromMagnitudeAndPhaseInDegrees(r, phi));

            case AngleMeasurement.Radians:
                return(ComplexNumberFromMagnitudeAndPhaseInRadians(r, phi));

            default:
                throw new ArgumentOutOfRangeException("Invalid angle measurement");
            }
        }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionParameters"/> class.
 /// </summary>
 /// <param name="angleMeasuremnt">The angle measuremnt.</param>
 /// <param name="variables">The collection of variables' values.</param>
 /// <param name="functions">The collection of user functions.</param>
 public ExpressionParameters(AngleMeasurement angleMeasuremnt, ParameterCollection variables, FunctionCollection functions)
 {
     this.angleMeasuremnt = angleMeasuremnt;
     this.variables = variables;
     this.functions = functions;
 }
Пример #15
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;
        }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionParameters"/> class.
 /// </summary>
 /// <param name="angleMeasuremnt">The angle measuremnt.</param>
 /// <param name="parameters">The collection of variables' values.</param>
 /// <param name="functions">The collection of user functions.</param>
 public ExpressionParameters(AngleMeasurement angleMeasuremnt, ParameterCollection parameters, FunctionCollection functions)
 {
     this.angleMeasuremnt = angleMeasuremnt;
     this.parameters = parameters;
     this.functions = functions;
 }
Пример #17
0
 public static Vector3 GetLabelWorldPosition(AngleMeasurement angle)
 {
     return(angle.Position + angle.AngleNormal * GetAngleDistance(angle.Flags));
 }