/// <summary> /// Default constructor. /// </summary> public Camera(Scene scene) { _scene = scene; // set default positioning _position = new Vector(0.0, 0.0, 9.0); _upVec = new Vector(0.0, 1.0, 0.0); _center = new Vector(); // set default field of view fov = new Angle(); fov["deg"] = 28.0; // set default interaction factors dollyFactor = 0.15; panFactor = 0.05; lastDirection = ViewDirection.Front; Frustum = new FrustumDef(); DefaultAnimationOptions.Duration = 4.0; DefaultAnimationOptions.EaseType = EaseType.Quadratic; UseInertia = true; InertiaAnimationOptions = new AnimationOptions() { Duration = 6.0, EaseType = EaseType.Linear }; InertiaType = InteractionType.None; }
public Camera() { _position = new Vector3(0.0f, 0.0f, 0.0f); _rotation = new Vector3(0.0f, 0.0f, 0.0f); _fieldOfView = Angle.CreateDegrees(90).Radians; _aspect = new Vector2(16, 9); }
void Start() { angle = GetComponent<Angle> (); speed = Random.Range (4, 12); EnemyManager.get().enemies.Add (this); }
public static void Create_Angle_Check_Value_Less_Than_Two_Pi() { Angle angle = new Angle(-3 * Math.PI); angle = angle.ReduceAngle(); Assert.AreEqual(Math.PI, angle.Value, 0.00001); }
public Arrow(Game g, Point p, Angle a, Angle z) : base(g, 0, 0, new ModelArrow(a, z, p)) { //texture = t; //origin = new Vector2(section.Width / 2, section.Height); world = Matrix.CreateTranslation(new Vector3(displayable.position.x, displayable.position.y, displayable.position.z)); }
public Coordinate(Angle aTheta, Angle aPhi) { iTheta = aTheta; iPhi = aPhi; InitVector(); }
// Update is called once per frame public void Move() { if ( !Dead && GameController.mode == 3 ) { DegreeAngle += dirrection * DegreesPerSecond * Time.deltaTime; transform.position = DegreeAngle.PointByRadius (Radius); //get radius changes ChangeRingDirrection = InputController.GetInput (); Radius += ChangeRingDirrection * RadiusLerpSpeed * Time.deltaTime; if ( Radius < InitialRadius ) Radius = InitialRadius; else if ( Radius > FinalRadius ) Radius = FinalRadius; //draw surrounding circle } else { if ( SurroundingCircle != null ) { foreach ( GameObject i in SurroundingCircle ) i.GetComponent<LineRenderer>().renderer.enabled = true; SurroundingCircle = null; } } }
// Return the shared angle in both congruences public Angle OtherAngle(Angle thatAngle) { if (angle1.Equates(thatAngle)) return angle2; if (angle2.Equates(thatAngle)) return angle1; return null; }
public void Revive() { DegreeAngle = 0f; Radius = NewRadius = InitialRadius; Dead = false; x = -1; }
public void VerifyAllEnums() { var acceleration = new Acceleration(1, AccelerationUnit.BaseUnit); var angle = new Angle(1, AngleUnit.BaseUnit); var angularAcceleration = new AngularAcceleration(1, AngularAccelerationUnit.BaseUnit); var area = new Area(1, AreaUnit.BaseUnit); var density = new MassDensity(1, MassDensityUnit.BaseUnit); var electricCurrent = new ElectricCurrent(1, ElectricCurrentUnit.BaseUnit); var electricResistance = new ElectricResistance(1, ElectricResistanceUnit.BaseUnit); var electricVoltage = new ElectricPotential(1, ElectricPotentialUnit.BaseUnit); var energy = new Energy(1, EnergyUnit.BaseUnit); var force = new Force(1, ForceUnit.BaseUnit); var frequency = new Frequency(1, FrequencyUnit.BaseUnit); var jerk = new Jerk(1, JerkUnit.BaseUnit); var length = new Length(1, LengthUnit.BaseUnit); var mass = new Mass(1, MassUnit.BaseUnit); var massFlowRate = new MassFlowRate(1, MassFlowRateUnit.BaseUnit); var momentum = new Momentum(1, MomentumUnit.BaseUnit); var numeric = new Numeric(1, NumericUnit.BaseUnit); var power = new Power(1, PowerUnit.BaseUnit); var pressure = new Pressure(1, PressureUnit.BaseUnit); var speed = new Speed(1, SpeedUnit.BaseUnit); var temperature = new Temperature(1, TemperatureUnit.BaseUnit); var time = new Time(1, TimeUnit.BaseUnit); var torque = new Torque(1, TorqueUnit.BaseUnit); var volume = new Volume(1, VolumeUnit.BaseUnit); var volumetricFlowRate = new VolumetricFlowRate(1, VolumetricFlowRateUnit.BaseUnit); }
public void TestSelection() { Point start, center, stop, p; Selection s; start = new Point (0, 10); stop = new Point (10, 0); center = new Point (0, 0); Angle a = new Angle (start, center, stop); p = new Point (0.1, 0.3); s = a.GetSelection (p, 0.5); Assert.AreEqual (SelectionPosition.AngleCenter, s.Position); Assert.AreEqual (p.Distance (center), s.Accuracy); p = new Point (9.8, 0.3); s = a.GetSelection (p, 0.5); Assert.AreEqual (SelectionPosition.AngleStop, s.Position); Assert.AreEqual (p.Distance (stop), s.Accuracy); p = new Point (0.2, 9.9); s = a.GetSelection (p, 0.5); Assert.AreEqual (SelectionPosition.AngleStart, s.Position); Assert.AreEqual (p.Distance (start), s.Accuracy); p = new Point (5, 5); s = a.GetSelection (p, 0.5); Assert.IsNull (s); }
public Hokuyo(LidarID lidar) { //trameDetails = "VV\n00P\n"; this.lidar = lidar; semLock = new Semaphore(1, 1); switch (lidar) { case LidarID.LidarSol: model = "URG-04LX-UG01"; break; } if (model.Contains("UBG-04LX-F01"))//Hokuyo bleu { nbPoints = 725; angleMesurable = new Angle(240, AnglyeType.Degre); offsetPoints = 44; } else if (model.Contains("URG-04LX-UG01")) //Petit hokuyo { nbPoints = 725; angleMesurable = new Angle(240, AnglyeType.Degre); offsetPoints = 44; } else if (model.Contains("BTM-75LX")) // Grand hokuyo { nbPoints = 1080; angleMesurable = new Angle(270, AnglyeType.Degre); offsetPoints = 0; } position = Robots.GrosRobot.Position; Robots.GrosRobot.PositionChange += GrosRobot_PositionChange; }
/// <summary> /// Вернёт frame, в котором повёрнуты координаты X и Y и Yaw равен переданному углу. /// </summary> static public Frame3D Rotate2D(Frame3D frame, Angle angle) { double x = frame.X * Math.Cos(angle.Radian) - frame.Y * Math.Sin(angle.Radian); double y = frame.X * Math.Sin(angle.Radian) + frame.Y * Math.Cos(angle.Radian); return new Frame3D(x, y, frame.Z, Angle.FromGrad(0), angle, Angle.FromGrad(0)); }
public Frame2D(double x, double y, Angle angle) { X = x; Y = y; Angle = angle; Center = new Point2D(x, y); }
public void TestAssignement() { Angle angle = new Angle(); angle.Degrees = 30.0; Assert.That(angle.Degrees, Is.EqualTo(30.0)); Assert.That(angle.Radians, Is.EqualTo(30.0 * Math.PI / 180.0)); }
public void Passing() { var angles = new Angle[51, 600]; var sw = Stopwatch.StartNew(); for (var p = 5f; p <= 10; p += 0.1f) { for (var d = 200; d < 800; d++) { var d2 = d* d; var power = new Power(p); var speed = power.Speed; for (var t = 1; t < 1024; t++) { if (p > 9.8f) { } var ball = BallPath.GetDistance(speed, t); var player = PlayerPath.GetDistance(3, t, 40); if (ball.Squared + player.Squared > d2) { var angle = Angle.Atan((double)player / (double)ball); break; } } } } Console.WriteLine(sw.Elapsed.TotalMilliseconds); }
/// <summary> /// Create a new triangle bounded by the 3 given segments. The set of points that define these segments should have only 3 distinct elements. /// </summary> /// <param name="a">The segment opposite point a</param> /// <param name="b">The segment opposite point b</param> /// <param name="c">The segment opposite point c</param> public Triangle(Segment a, Segment b, Segment c) : base(a, b, c) { SegmentA = a; SegmentB = b; SegmentC = c; Point1 = SegmentA.Point1; Point2 = SegmentA.Point2; Point3 = Point1.Equals(SegmentB.Point1) || Point2.Equals(SegmentB.Point1) ? SegmentB.Point2 : SegmentB.Point1; AngleA = new Angle(Point1, Point2, Point3); AngleB = new Angle(Point2, Point3, Point1); AngleC = new Angle(Point3, Point1, Point2); isRight = isRightTriangle(); provenRight = false; givenRight = false; isIsosceles = IsIsosceles(); provenIsosceles = false; isEquilateral = IsEquilateral(); provenEquilateral = false; congruencePairs = new List<Triangle>(); similarPairs = new List<Triangle>(); addSuperFigureToDependencies(); }
private static List<EdgeAggregator> CheckAndGeneratePerpendicularImplyCongruentAdjacent(Perpendicular perp, Angle angle1, Angle angle2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); if (!Utilities.CompareValues(angle1.measure + angle2.measure, 90)) return newGrounded; // The perpendicular intersection must occur at the same vertex of both angles (we only need check one). if (!(angle1.GetVertex().Equals(perp.intersect) && angle2.GetVertex().Equals(perp.intersect))) return newGrounded; // Are the angles adjacent? Segment sharedRay = angle1.IsAdjacentTo(angle2); if (sharedRay == null) return newGrounded; // Do the non-shared rays for both angles align with the segments defined by the perpendicular intersection? if (!perp.DefinesBothRays(angle1.OtherRayEquates(sharedRay), angle2.OtherRayEquates(sharedRay))) return newGrounded; // // Now we have perpendicular -> complementary angles scenario // Complementary cas = new Complementary(angle1, angle2); // Construct hyperedge List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(perp); antecedent.Add(angle1); antecedent.Add(angle2); newGrounded.Add(new EdgeAggregator(antecedent, cas, annotation)); return newGrounded; }
public CadViewPort(String name, Model parentMdl, Point center, Double height, Double width, Vector scaleVec, Angle rotation) : this(name, parentMdl, center, new Vector(width, height, null), scaleVec, rotation) { }
public Seg(World world,Vertex start,Vertex end,Linedef linedef,bool isbackside,Angle angle,Fixed offset) { if (world == null) throw new ArgumentNullException("world"); if (start == null) throw new ArgumentNullException("start"); if (end == null) throw new ArgumentNullException("end"); if (linedef == null) throw new ArgumentNullException("linedef"); if (start.World != world) throw new ArgumentException("Start vertex is from another world."); if (end.World != world) throw new ArgumentException("End vertex is from another world."); if (linedef.World != world) throw new ArgumentException("Linedef is from another world."); this.world = world; // TODO :: start // TODO :: end // TODO :: linedef if (!isbackside) { this.front = linedef.Front; this.back = linedef.Back; } else { this.front = linedef.Back; this.back = linedef.Front; } // TODO :: angle // TODO :: offset }
public static Transformation RaDec2Ah(Angle aLattitude) { Transformation theTransformation = new Transformation(); theTransformation.Rotate(Axes.Y, aLattitude.Radians - 0.5 * Math.PI); return theTransformation; }
private static List<EdgeAggregator> InstantiateTheorem(Angle a1, Angle a2) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // Acquire all circles in which the angles are inscribed List<Circle> circles1 = Circle.IsInscribedAngle(a1); List<Circle> circles2 = Circle.IsInscribedAngle(a2); //Acquire the common circles in which both angles are inscribed List<Circle> circles = (circles1.Intersect(circles2)).ToList(); //For each common circle, check for equivalent itercepted arcs foreach (Circle c in circles) { Arc i1 = Arc.GetInterceptedArc(c, a1); Arc i2 = Arc.GetInterceptedArc(c, a2); if (i1.StructurallyEquals(i2)) { GeometricCongruentAngles gcas = new GeometricCongruentAngles(a1, a2); //For hypergraph List<GroundedClause> antecedent = new List<GroundedClause>(); antecedent.Add(c); antecedent.Add(a1); antecedent.Add(a2); antecedent.Add(i1); newGrounded.Add(new EdgeAggregator(antecedent, gcas, annotation)); } } return newGrounded; }
/// <summary> /// Constructor. /// </summary> /// <param name="start">Start point.</param> /// <param name="direction">Angular direction of the vector</param> /// <param name="magnitude">Magnitude of the vector.</param> public EuclideanVector(Point start, Angle direction, float magnitude) { Start = start; Direction = direction; Magnitude = magnitude; End = CalculateEndPoint(start, direction, magnitude); }
public bool Between(Angle cLimit, Angle ccLimit) { if (cLimit.Value < ccLimit.Value) { return this.Value >= cLimit.Value && this.Value <= ccLimit.Value; } return this.Value >= cLimit.Value || this.Value <= ccLimit.Value; }
public void OpAddition() { var angle1 = new Angle(180, AngleUnit.Degree); var angle2 = new Angle(200, AngleUnit.Grad); var expected = new Angle(360, AngleUnit.Degree); (angle1 + angle2).ShouldEqual(expected); (angle2 + angle1).ShouldEqual(expected); }
/// <summary> /// повернуть фрейм вокруг вертикальной оси (z) /// </summary> /// <param name="frame">положение сонара</param> /// <param name="angle">угол поворота</param> /// <returns>вектор - новое направление</returns> public static Frame3D HorisontalFrameRotation(Frame3D frame, Angle angle) { Matrix m = frame.GetMatrix(); //var up = new Point3D(m[0, 2], m[1, 2], m[2, 2]); var up = new Point3D(0,0,1); Frame3D rotated = frame.Apply(Frame3D.DoRotate(up, angle)); return rotated; }
public Complementary(Angle ang1, Angle ang2) : base(ang1, ang2) { if (!Utilities.CompareValues(ang1.measure + ang2.measure, 90)) { throw new ArgumentException("Complementary Angles must sum to 90: " + ang1 + " " + ang2); } }
public TwoVector RotateAbout(TwoVector CenterPoint, Angle angle) { double startingX = this.ci - CenterPoint.ci; double startingY = this.cj - CenterPoint.cj; double xPos = (startingX) * Math.Cos(angle.InRadians()) - (startingY) * Math.Sin(angle.InRadians()); double yPos = (startingX) * Math.Sin(angle.InRadians()) + (startingY) * Math.Cos(angle.InRadians()); return new TwoVector(xPos + CenterPoint.ci, yPos + CenterPoint.cj); }
/// <summary> /// повернуть фрейм вокруг горизонтальной оси (y) /// </summary> /// <param name="frame">положение сонара</param> /// <param name="angle">угол поворота</param> /// <returns>вектор - новое направление</returns> public static Frame3D VerticalFrameRotation(Frame3D frame, Angle angle) { Matrix m = frame.GetMatrix(); //var right = new Point3D(m[0, 1], m[1, 1], m[2, 1]); var right = new Point3D(0,-1,0); Frame3D rotated = frame.Apply(Frame3D.DoRotate(right, angle)); return rotated; }
public CadViewPort(String name, CadViewPort other) : this(name, other.parentModel) { Height = other.Height; Width = other.Width; Origin = new Point(other.Origin); ScaleVector = new Vector(other.ScaleVector.x, other.ScaleVector.y, other.ScaleVector.z); Rotation = new Angle(other.Rotation.angle_); }
/// <summary> /// Deserializes a complex value. /// </summary> /// <param name="reader">The reader.</param> /// <param name="context">The serialization context to use.</param> /// <param name="valueInfo">The value information. Can be <c>null</c>.</param> /// <param name="valueType">The type of the value to deserialize.</param> /// <returns>The deserialized value.</returns> private object DeserializeComplexValue(BinaryReader reader, ISerializationContext context, TagFieldAttribute valueInfo, Type valueType) { // Indirect objects // TODO: Remove ResourceReference hax, the Indirect flag wasn't available when I generated the tag structures if (valueInfo != null && ((valueInfo.Flags & TagFieldFlags.Indirect) != 0 || valueType == typeof(ResourceReference))) { return(DeserializeIndirectValue(reader, context, valueType)); } // enum = Enum type if (valueType.IsEnum) { return(DeserializePrimitiveValue(reader, valueType.GetEnumUnderlyingType())); } // string = ASCII string if (valueType == typeof(string)) { return(DeserializeString(reader, valueInfo)); } // TagInstance = Tag reference if (valueType == typeof(TagInstance)) { return(DeserializeTagReference(reader, context, valueInfo)); } // ResourceAddress = Resource address if (valueType == typeof(ResourceAddress)) { return(new ResourceAddress(reader.ReadUInt32())); } // Byte array = Data reference // TODO: Allow other types to be in data references, since sometimes they can point to a structure if (valueType == typeof(byte[])) { return(DeserializeDataReference(reader, context)); } // Euler Angles types if (valueType == typeof(Euler2)) { var i = Angle.FromRadians(reader.ReadSingle()); var j = Angle.FromRadians(reader.ReadSingle()); return(new Euler2(i, j)); } else if (valueType == typeof(Euler3)) { var i = Angle.FromRadians(reader.ReadSingle()); var j = Angle.FromRadians(reader.ReadSingle()); var k = Angle.FromRadians(reader.ReadSingle()); return(new Euler3(i, j, k)); } // Vector types if (valueType == typeof(Vector2)) { return(new Vector2(reader.ReadSingle(), reader.ReadSingle())); } if (valueType == typeof(Vector3)) { return(new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle())); } if (valueType == typeof(Vector4)) { return(new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle())); } // StringID if (valueType == typeof(StringId)) { return(new StringId(reader.ReadUInt32())); } // Angle (radians) if (valueType == typeof(Angle)) { return(Angle.FromRadians(reader.ReadSingle())); } // Non-byte array = Inline array // TODO: Define more clearly in general what constitutes a data reference and what doesn't if (valueType.IsArray) { return(DeserializeInlineArray(reader, context, valueInfo, valueType)); } // List = Tag block if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(List <>)) { return(DeserializeTagBlock(reader, context, valueType)); } // Ranges if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Range <>)) { return(DeserializeRange(reader, context, valueType)); } // Assume the value is a structure return(DeserializeStruct(reader, context, new TagStructureInfo(valueType, _version))); }
/// <summary> /// Enumeration to decide which the Parent Change is. That is, the Entry point of the Setup Change Closed Loop Solver /// </summary> /// <summary> /// Overloaded constructor to <see cref="SolverMasterClass"/> and <see cref="OutputClass"/> and <see cref="SetupChange_CornerVariables"/> along with lists /// </summary> /// <param name="_sMC"></param> /// <param name="_oC"></param> /// <param name="_setupChange_DB_Dictionary"></param> public SetupChange_ClosedLoopSolver(SolverMasterClass _sMC, List <OutputClass> _oC, ref Dictionary <string, double> _setupChange_DB_Dictionary, Angle _finalCamber, Angle _finalToe, Angle _finalCaster, Angle _finalKPI) { ///<summary>Assining the object of the <see cref="SolverMasterClass"/></summary> SMC = _sMC; ///<summary>Assining the object of the <see cref="OutputClass"/></summary> OC = _oC; ///<summary>Assining the object of the <see cref="SetupChange_CornerVariables"/></summary> SetupChange_CV_Base = new SetupChange_CornerVariables(); SetupChange_CV_Base = OC[0].sccvOP; ///<summary>Assining the object of the <see cref="SetupChangeDatabase"/></summary> SetupChange_DB = SMC.SetupChange_DB_Master; ///<remarks>---OBSELETE---</remarks> SetupChange_DB_Dictionary = _setupChange_DB_Dictionary; ///<summary>Initializing all the Lists of this class which will be used for the Setup Change Verificating and History maintainance</summary> InitializeLists(); ///<summary>Creating delegates which will be stored in a master Multicast Delegate. This master delegate will the Invocation list and will call the methods according to that lsit </summary> invokeCamberClosedLoop = new MethodInvocationOrderDecider(ClosedLoop_ChangeCamber_Invoker); invokeToeClosedLoop = new MethodInvocationOrderDecider(ClosedLoop_ChangeToe_Invoker); invokeCasterClosedLoop = new MethodInvocationOrderDecider(ClosedLoop_ChangeCaster_Invoker); invokeKPIClosedLoop = new MethodInvocationOrderDecider(ClosedLoop_ChangeKPI_Invoker); invokeLinkLengthClosedLoop = new MethodInvocationOrderDecider(ClosedLoop_ChangeLinkLengths_Invoker); ///<summary>Dumping all the above delegates into the Multicast delegate. This will be sorted eventually based on the entry point to the closed loop </summary> AssignMulticastDelegate(); FinalCamber = _finalCamber; FinalToe = _finalToe; FinalCaster = _finalCaster; FinalKPI = _finalKPI; }
public void WriteAngle(Angle angle) { BaseStream.WriteByte(angle.Value); }
public async Task WriteAngleAsync(Angle angle) { await WriteByteAsync((sbyte)angle.Value); // await this.WriteUnsignedByteAsync((byte)(angle / Angle.MaxValue * byte.MaxValue)); }
/// <summary> /// Käännetään pudotustasoa /// </summary> /// <param name="kulma">millä kulmalla käännetään</param> private void KaannaMailaa(double kulma) { maila.Angle += Angle.FromDegrees(kulma); }
public Transform(Vector2 position, Angle angle) { Position = position; Quaternion2D = new Quaternion2D(angle); }
public void TestDegrees(double expectedRadians, double degrees) { var angle = new Angle(degrees, MeasurementType.Degrees); Assert.LessOrEqual(Math.Abs(expectedRadians - angle.Radians), Epsilon); }
/// <summary> /// Returns a polygon rotated around the origin /// </summary> /// <param name="angle">The angle by which to rotate.</param> /// <returns>A new polygon that has been rotated.</returns> public Polygon2D Rotate(Angle angle) { var rotated = this.points.Select(t => Point2D.Origin + t.ToVector2D().Rotate(angle)).ToArray(); return(new Polygon2D(rotated)); }
public void CompareToThrowsOnNull() { Angle degree = Angle.FromDegrees(1); Assert.Throws <ArgumentNullException>(() => degree.CompareTo(null)); }
private void RefreshTelescope() { if (!panelTelescope.Visible) { return; } DateTime now = DateTime.Now; DateTime utc = now.ToUniversalTime(); ASCOM.Utilities.Util u = new ASCOM.Utilities.Util(); labelLTValue.Text = now.TimeOfDay.ToString(@"hh\hmm\mss\.f\s"); labelUTValue.Text = utc.TimeOfDay.ToString(@"hh\hmm\mss\.f\s"); if (wisetele.Connected) { groupBoxTelescope.Text = string.Format(" {0} v{1} ", wisetele.Name, wisetele.DriverVersion); labelSiderealValue.Text = wisesite.LocalSiderealTime.ToString(); labelRightAscensionValue.Text = Angle.FromHours(wisetele.RightAscension).ToNiceString(); labelDeclinationValue.Text = Angle.FromDegrees(wisetele.Declination).ToNiceString(); labelHourAngleValue.Text = Angle.FromHours(wisetele.HourAngle, Angle.Type.HA).ToNiceString(); labelAltitudeValue.Text = Angle.FromDegrees(wisetele.Altitude).ToNiceString(); labelAzimuthValue.Text = Angle.FromDegrees(wisetele.Azimuth).ToNiceString(); labelHAEncValue.Text = wisetele.HAEncoder.Value.ToString(); labelDecEncValue.Text = wisetele.DecEncoder.Value.ToString(); axisValue.Text = wisetele.HAEncoder.AxisValue.ToString(); wormValue.Text = wisetele.HAEncoder.WormValue.ToString(); checkBoxPrimaryIsActive.Checked = wisetele.AxisIsMoving(TelescopeAxes.axisPrimary); checkBoxSecondaryIsActive.Checked = wisetele.AxisIsMoving(TelescopeAxes.axisSecondary); checkBoxSlewingIsActive.Checked = wisetele.Slewing; checkBoxTrackingIsActive.Checked = wisetele.Tracking; checkBoxTrack.Checked = wisetele.Tracking; } else { groupBoxTelescope.Text = " Telescope (not connected) "; labelSiderealValue.Text = string.Empty; labelRightAscensionValue.Text = string.Empty; labelDeclinationValue.Text = string.Empty; labelHourAngleValue.Text = string.Empty; labelAltitudeValue.Text = string.Empty; labelAzimuthValue.Text = string.Empty; labelHAEncValue.Text = string.Empty; labelDecEncValue.Text = string.Empty; axisValue.Text = string.Empty; wormValue.Text = string.Empty; checkBoxPrimaryIsActive.Checked = false; checkBoxSecondaryIsActive.Checked = false; checkBoxSlewingIsActive.Checked = false; checkBoxTrackingIsActive.Checked = false; checkBoxTrack.Checked = false; } }
public PointF PositionOfIndex(Double indexValue) { if (Shape.IsPolygon) { int floor = (int)Math.Floor(indexValue); int ceiling = (int)Math.Ceiling(indexValue); PointF prev = PositionOfIndex(floor); PointF next = PositionOfIndex(ceiling); double x, y; x = next.X - (next.X - prev.X) * (ceiling - indexValue); y = next.Y - (next.Y - prev.Y) * (ceiling - indexValue); return(new PointF((float)x, (float)y)); } else { indexValue = (indexValue <= 360.5 ? indexValue : Math.Round(indexValue % 360, 2)); int ceiling = (int)Math.Ceiling(indexValue); double x, y; if (ceiling % Shape.Edges == 1) { if (indexValue == ceiling - 0.5) { int round = Shape.RoundOf(ceiling); Double tan = Math.Tan(Math.PI / Shape.Edges); Double radius = 0.5 / tan + round - 1.5; return(new PointF((float)radius, 0)); } int floor = (int)Math.Floor(indexValue); PointF prev = PositionOfIndex(floor); PointF next = PositionOfIndex(ceiling); x = next.X - (next.X - prev.X) * (ceiling - indexValue); y = next.Y - (next.Y - prev.Y) * (ceiling - indexValue); return(new PointF((float)x, (float)y)); } else { Angle ceilingAngle = Shape.Vertices[(ceiling + Shape.Edges - 1) % Shape.Edges]; int round = Shape.RoundOf(indexValue); Double tan = Math.Tan(Math.PI / Shape.Edges); Double radius = 0.5 / tan + round - 1; int first = Shape.FirstOfRound(round); float degree = (float)(ceilingAngle.Degrees - (ceiling - indexValue) * 360.0 / Edges); x = radius * COS(degree); y = radius * SIN(degree); return(new PointF((float)x, (float)y)); } } }
public void EqualsReturnsFalseOnNull() { Angle degree = Angle.FromDegrees(1); Assert.False(degree.Equals(null)); }
internal PolarGraphics(Graphics g, Rectangle visibleClipBounds, Angle rotation, Azimuth origin, PolarCoordinateOrientation orientation, float centerR, float maximumR)
bool IAttack.WideAttack(AttackEventArgs eventArgs) { if (!eventArgs.WideAttack) { return(true); } var curTime = _gameTiming.CurTime; if (curTime < _cooldownEnd) { return(true); } var location = eventArgs.User.Transform.Coordinates; var angle = new Angle(eventArgs.ClickLocation.ToMapPos(Owner.EntityManager) - location.ToMapPos(Owner.EntityManager)); // This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes. var entities = ArcRayCast(eventArgs.User.Transform.WorldPosition, angle, eventArgs.User); var audioSystem = EntitySystem.Get <AudioSystem>(); if (entities.Count() != 0) { audioSystem.PlayFromEntity(_hitSound, entities.First()); } else { audioSystem.PlayFromEntity(_missSound, eventArgs.User); } var hitEntities = new List <IEntity>(); foreach (var entity in entities) { if (!entity.Transform.IsMapTransform || entity == eventArgs.User) { continue; } if (entity.TryGetComponent(out IDamageableComponent damageComponent)) { damageComponent.ChangeDamage(DamageType, Damage, false, Owner); hitEntities.Add(entity); } } if (!OnHitEntities(hitEntities, eventArgs)) { return(false); } if (Arc != null) { var sys = EntitySystem.Get <MeleeWeaponSystem>(); sys.SendAnimation(Arc, angle, eventArgs.User, Owner, hitEntities); } _lastAttackTime = curTime; _cooldownEnd = _lastAttackTime + TimeSpan.FromSeconds(ArcCooldownTime); if (Owner.TryGetComponent(out ItemCooldownComponent cooldown)) { cooldown.CooldownStart = _lastAttackTime; cooldown.CooldownEnd = _cooldownEnd; } return(true); }
/** * Computes a Cartesian point at a specified location on the terrain. * * @param latitude the latitude of the point to compute. * @param longitude the longitude of the point to compute. * * @return the Cartesian point, in meters, relative to an origin of (0, 0, 0). Will be null if there is no sector * geometry in this list for the specifed latitude and longitude. */ public Vec4 getSurfacePoint(Angle latitude, Angle longitude) { return(this.getSurfacePoint(latitude, longitude, 0d)); }
private void FixedUpdate() { #region Wrap/Unwrap //Unwrap if (Count > 1) { if (!foundEdge) { FindEdge(); } else { DoUnwrapGeometry(); } //Determine if the edge is still 'holding onto' the rope. dot = Vector2.Dot(normal, pathNrml); angle = Geometry.HeadToTailAngle(Segment1, Segment2); if ( angle.Abs() > 170 && dot > 0 ) { Unwrap(); } } //Wrap if (Count > 0) { Vector2 toEndpoint = Point2 - Position; RaycastHit2D hit = Physics2D.Raycast(Position, toEndpoint, toEndpoint.magnitude - error1); if (hit) { Wrap(hit.point, hit.collider); } } #endregion #region Spiderman Physics if (connected) { distance = Vector2.Distance(Position, swingpoint); hasTension = (distance > length); if (hasTension) { #region G _perpendicular (Gp) //solving for the perpendicular component of gravity relative to the endpoint. float G = Physics2D.gravity.magnitude; float ThetaGE = Vector2.SignedAngle( swingpoint - (Vector2)transform.position, Physics2D.gravity ); float ThetaGR = Vector2.SignedAngle( Vector2.right, Physics2D.gravity ); float ThetaGpR = ThetaGR - ThetaGE + 90; ThetaGE *= Mathf.Deg2Rad; ThetaGpR *= Mathf.Deg2Rad; float Gpx = G * Mathf.Sin(ThetaGE) * Mathf.Cos(ThetaGpR); float Gpy = G * Mathf.Sin(ThetaGE) * Mathf.Sin(ThetaGpR); Vector2 Gp = new Vector2(Gpx, Gpy); #endregion Vector2 p = Vector2.Lerp(Position, swingpoint, (distance - length) / distance); Vector2 v = TangentVelocity(rigidbody, gameObject, swingpoint); v *= ((distance - length) / length) + 1.0f; v += Gp * Time.fixedDeltaTime; rigidbody.MovePosition((v * Time.fixedDeltaTime) + p); rigidbody.velocity = v; distance = length; } } else { hasTension = false; } #endregion }
public void WriteFloatAngle(Angle angle) { WriteFloat(angle.Degrees); }
public void CheckMathRoundIsUsed() { Assert.AreEqual(123, Angle.ConvertToDegree(Angle.ConvertToRadian(123))); Assert.AreEqual(125, Angle.ConvertToDegree(Angle.ConvertToRadian(125))); }
public static Matrix <double> RotationAroundArbitraryVector(UnitVector3D aboutVector, Angle angle) { // http://en.wikipedia.org/wiki/Rotation_matrix var unitTensorProduct = aboutVector.GetUnitTensorProduct(); var crossproductMatrix = aboutVector.CrossProductMatrix; // aboutVector.Clone().CrossProduct(aboutVector.Clone()); var r1 = DenseMatrix.CreateIdentity(3).Multiply(Math.Cos(angle.Radians)); var r2 = crossproductMatrix.Multiply(Math.Sin(angle.Radians)); var r3 = unitTensorProduct.Multiply(1 - Math.Cos(angle.Radians)); var totalR = r1.Add(r2).Add(r3); return(totalR); }
private void VaihdaPainovoimaa() { Gravity = Vector.FromLengthAndAngle(Gravity.Magnitude, Gravity.Angle + Angle.FromDegrees(90.0)); }
/// <summary> /// /// </summary> /// <param name="aboutVector"></param> /// <param name="angle">Angle in degrees</param> /// <param name="angleUnit"></param> /// <returns></returns> public static Matrix <double> RotationAroundArbitraryVector <T>(UnitVector3D aboutVector, double angle, T angleUnit) where T : IAngleUnit { return(RotationAroundArbitraryVector(aboutVector, Angle.From(angle, angleUnit))); }
public override void Initialize(DrawArgs drawArgs) { double samplesPerDegree = 50.0 / (drawArgs.WorldCamera.ViewRange.Degrees); double elevation = drawArgs.CurrentWorld.TerrainAccessor.GetElevationAt(m_latitude, m_longitude, samplesPerDegree); double altitude = (World.Settings.VerticalExaggeration * Altitude + World.Settings.VerticalExaggeration * elevation); Position = MathEngine.SphericalToCartesian(m_latitude, m_longitude, altitude + drawArgs.WorldCamera.WorldRadius); m_positionD = MathEngine.SphericalToCartesianD(Angle.FromDegrees(m_latitude), Angle.FromDegrees(m_longitude), altitude + drawArgs.WorldCamera.WorldRadius); Inited = true; }
/// <inheritdoc /> public IEnumerable <IEntity> GetEntitiesInArc(GridCoordinates coordinates, float range, Angle direction, float arcWidth, bool approximate = false) { var position = coordinates.ToMap(_mapManager).Position; foreach (var entity in GetEntitiesInRange(coordinates, range * 2, approximate)) { var angle = new Angle(entity.Transform.WorldPosition - position); if (angle.Degrees < direction.Degrees + arcWidth / 2 && angle.Degrees > direction.Degrees - arcWidth / 2) { yield return(entity); } } }
public void CompareToThrowsOnTypeMismatch() { Angle degree = Angle.FromDegrees(1); Assert.Throws <ArgumentException>(() => degree.CompareTo(new object())); }
public static double[,] RotationMatrixAboutZ(Angle rotationAngle) => new Rotation(Line.ZAxis, rotationAngle).Matrix;
public Page5Row6Prob19(bool onoff, bool complete) : base(onoff, complete) { Point a = new Point("A", 0, 0); points.Add(a); Point b = new Point("B", -3.5, 3.5); points.Add(b); Point c = new Point("C", -3.5, 7); points.Add(c); Point d = new Point("D", 0, 7); points.Add(d); Point e = new Point("E", 0, 3.5); points.Add(e); Point f = new Point("F", 7, 3.5); points.Add(f); Point g = new Point("G", 7, 0); points.Add(g); Segment cd = new Segment(c, d); segments.Add(cd); Segment bc = new Segment(b, c); segments.Add(bc); Segment fg = new Segment(f, g); segments.Add(fg); Segment ag = new Segment(a, g); segments.Add(ag); circles.Add(new Circle(e, 3.5)); //Quadrilateral quad = (Quadrilateral)parser.Get(new Quadrilateral(bc, cd, de, eb)); //Quadrilateral quad = (Quadrilateral)parser.Get(new Quadrilateral(ef, fg, ga, ae)); List <Point> pts = new List <Point>(); pts.Add(a); pts.Add(e); pts.Add(d); collinear.Add(new Collinear(pts)); pts = new List <Point>(); pts.Add(b); pts.Add(e); pts.Add(f); collinear.Add(new Collinear(pts)); parser = new GeometryTutorLib.TutorParser.HardCodedParserMain(points, collinear, segments, circles, onoff); Angle a1 = (Angle)parser.Get(new Angle(b, c, d)); Angle a2 = (Angle)parser.Get(new Angle(a, g, f)); Angle a3 = (Angle)parser.Get(new Angle(e, f, g)); Angle a4 = (Angle)parser.Get(new Angle(d, e, f)); given.Add(new Strengthened(a1, new RightAngle(a1))); given.Add(new Strengthened(a2, new RightAngle(a2))); given.Add(new Strengthened(a3, new RightAngle(a3))); given.Add(new Strengthened(a4, new RightAngle(a4))); given.Add(new GeometricSegmentEquation(bc, new NumericValue(3.5))); given.Add(new GeometricSegmentEquation(cd, new NumericValue(3.5))); given.Add(new GeometricSegmentEquation(fg, new NumericValue(3.5))); known.AddSegmentLength(bc, 3.5); known.AddSegmentLength(cd, 3.5); known.AddSegmentLength(fg, 3.5); known.AddSegmentLength((Segment)parser.Get(new Segment(e, f)), 7); List <Point> unwanted = new List <Point>(); unwanted.Add(new Point("", 1, 3.7)); unwanted.Add(new Point("", 3.4, 3.7)); goalRegions = parser.implied.GetAllAtomicRegionsWithoutPoints(unwanted); SetSolutionArea(36.75 + System.Math.PI * (12.25 / 4)); problemName = "McDougall Page 5 Row 6 Problem 19"; GeometryTutorLib.EngineUIBridge.HardCodedProblemsToUI.AddProblem(problemName, points, circles, segments); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (Option.SeriesCount == 0) { SetPieAndAzIndex(-1, -1); return; } for (int pieIndex = 0; pieIndex < Option.SeriesCount; pieIndex++) { for (int azIndex = 0; azIndex < Option.Series[pieIndex].Data.Count; azIndex++) { Angle angle = Angles[pieIndex][azIndex]; PointF pf = angle.Center; if (MathEx.CalcDistance(e.Location, pf) > angle.Outer) { continue; } if (MathEx.CalcDistance(e.Location, pf) < angle.Inner) { continue; } double az = MathEx.CalcAngle(e.Location, pf); if (az >= angle.Start && az <= angle.Start + angle.Sweep) { SetPieAndAzIndex(pieIndex, azIndex); if (tip.Text != angle.Text) { tip.Text = angle.Text; tip.Size = new Size((int)angle.TextSize.Width + 4, (int)angle.TextSize.Height + 4); } if (az >= 0 && az < 90) { tip.Top = e.Location.Y + 20; tip.Left = e.Location.X - tip.Width; } else if (az >= 90 && az < 180) { tip.Left = e.Location.X - tip.Width; tip.Top = e.Location.Y - tip.Height - 2; } else if (az >= 180 && az < 270) { tip.Left = e.Location.X; tip.Top = e.Location.Y - tip.Height - 2; } else if (az >= 270 && az < 360) { tip.Left = e.Location.X + 15; tip.Top = e.Location.Y + 20; } if (Option.ToolTip.Visible) { if (!tip.Visible) { tip.Visible = angle.Text.IsValid(); } } return; } } } SetPieAndAzIndex(-1, -1); tip.Visible = false; }
public void ToUnit() { var degree = Angle.FromDegrees(1); var arcminuteQuantity = degree.ToUnit(AngleUnit.Arcminute); AssertEx.EqualTolerance(ArcminutesInOneDegree, (double)arcminuteQuantity.Value, ArcminutesTolerance); Assert.Equal(AngleUnit.Arcminute, arcminuteQuantity.Unit); var arcsecondQuantity = degree.ToUnit(AngleUnit.Arcsecond); AssertEx.EqualTolerance(ArcsecondsInOneDegree, (double)arcsecondQuantity.Value, ArcsecondsTolerance); Assert.Equal(AngleUnit.Arcsecond, arcsecondQuantity.Unit); var centiradianQuantity = degree.ToUnit(AngleUnit.Centiradian); AssertEx.EqualTolerance(CentiradiansInOneDegree, (double)centiradianQuantity.Value, CentiradiansTolerance); Assert.Equal(AngleUnit.Centiradian, centiradianQuantity.Unit); var deciradianQuantity = degree.ToUnit(AngleUnit.Deciradian); AssertEx.EqualTolerance(DeciradiansInOneDegree, (double)deciradianQuantity.Value, DeciradiansTolerance); Assert.Equal(AngleUnit.Deciradian, deciradianQuantity.Unit); var degreeQuantity = degree.ToUnit(AngleUnit.Degree); AssertEx.EqualTolerance(DegreesInOneDegree, (double)degreeQuantity.Value, DegreesTolerance); Assert.Equal(AngleUnit.Degree, degreeQuantity.Unit); var gradianQuantity = degree.ToUnit(AngleUnit.Gradian); AssertEx.EqualTolerance(GradiansInOneDegree, (double)gradianQuantity.Value, GradiansTolerance); Assert.Equal(AngleUnit.Gradian, gradianQuantity.Unit); var microdegreeQuantity = degree.ToUnit(AngleUnit.Microdegree); AssertEx.EqualTolerance(MicrodegreesInOneDegree, (double)microdegreeQuantity.Value, MicrodegreesTolerance); Assert.Equal(AngleUnit.Microdegree, microdegreeQuantity.Unit); var microradianQuantity = degree.ToUnit(AngleUnit.Microradian); AssertEx.EqualTolerance(MicroradiansInOneDegree, (double)microradianQuantity.Value, MicroradiansTolerance); Assert.Equal(AngleUnit.Microradian, microradianQuantity.Unit); var millidegreeQuantity = degree.ToUnit(AngleUnit.Millidegree); AssertEx.EqualTolerance(MillidegreesInOneDegree, (double)millidegreeQuantity.Value, MillidegreesTolerance); Assert.Equal(AngleUnit.Millidegree, millidegreeQuantity.Unit); var milliradianQuantity = degree.ToUnit(AngleUnit.Milliradian); AssertEx.EqualTolerance(MilliradiansInOneDegree, (double)milliradianQuantity.Value, MilliradiansTolerance); Assert.Equal(AngleUnit.Milliradian, milliradianQuantity.Unit); var nanodegreeQuantity = degree.ToUnit(AngleUnit.Nanodegree); AssertEx.EqualTolerance(NanodegreesInOneDegree, (double)nanodegreeQuantity.Value, NanodegreesTolerance); Assert.Equal(AngleUnit.Nanodegree, nanodegreeQuantity.Unit); var nanoradianQuantity = degree.ToUnit(AngleUnit.Nanoradian); AssertEx.EqualTolerance(NanoradiansInOneDegree, (double)nanoradianQuantity.Value, NanoradiansTolerance); Assert.Equal(AngleUnit.Nanoradian, nanoradianQuantity.Unit); var radianQuantity = degree.ToUnit(AngleUnit.Radian); AssertEx.EqualTolerance(RadiansInOneDegree, (double)radianQuantity.Value, RadiansTolerance); Assert.Equal(AngleUnit.Radian, radianQuantity.Unit); var revolutionQuantity = degree.ToUnit(AngleUnit.Revolution); AssertEx.EqualTolerance(RevolutionsInOneDegree, (double)revolutionQuantity.Value, RevolutionsTolerance); Assert.Equal(AngleUnit.Revolution, revolutionQuantity.Unit); }
public GlobalCoordinates(Angle latitude, Angle longitude) { this.Latitude = latitude; this.Longitude = longitude; this.Canonicalize(); }
public void EqualsReturnsFalseOnTypeMismatch() { Angle degree = Angle.FromDegrees(1); Assert.False(degree.Equals(new object())); }