public void VectorXAndYCalculatedCorrectly2() { var v = new Vector(Angle.FromDegrees(30), 5); Assert.AreEqual(2.5, PointCalculator.GetVectorX(v), 0.1); Assert.AreEqual(4.3, PointCalculator.GetVectorY(v), 0.1); }
public void VectorXAndYCalculatedCorrectly7() { var v = new Vector(Angle.FromDegrees(320), 3.9); Assert.AreEqual(-2.5, PointCalculator.GetVectorX(v), 0.1); Assert.AreEqual(3, PointCalculator.GetVectorY(v), 0.1); }
public void VectorXAndYCalculatedCorrectly6() { var v = new Vector(Angle.FromDegrees(250), 4.3); Assert.AreEqual(-4, PointCalculator.GetVectorX(v), 0.1); Assert.AreEqual(-1.5, PointCalculator.GetVectorY(v), 0.1); }
public Level(XmlDocument xmlDoc) { XmlNode levelNode = xmlDoc.SelectSingleNode("/level"); extractLevelDetails(levelNode); XmlNode objectivesNode = xmlDoc.SelectSingleNode("/level/objectives"); objectives = new Objectives(objectivesNode); XmlNode pointCalculatorNode = xmlDoc.SelectSingleNode("/level/pointCalculator"); pointCalculator = new PointCalculator(pointCalculatorNode); XmlNode vehicleColorsNode = xmlDoc.SelectSingleNode("/level/vehicleColors"); vehicleColors = new VehicleColors(vehicleColorsNode); XmlNode humanRandomizerNode = xmlDoc.SelectSingleNode("/level/humanRandomizer"); humanRandomizer = new Randomizer(humanRandomizerNode, "human"); XmlNode vehicleRandomizerNode = xmlDoc.SelectSingleNode("/level/vehicleRandomizer"); vehicleRandomizer = new Randomizer(vehicleRandomizerNode, "vehicle"); XmlNode vehiclesDistributionNode = xmlDoc.SelectSingleNode("/level/vehicleDistributions"); extractVehiclesDistributions(vehiclesDistributionNode); XmlNode setupNode = xmlDoc.SelectSingleNode("/level/setup"); setup = new Setup(setupNode); }
public void AngleCalculatedCorrectly8() { var p1 = new PointF(5, 5); var p2 = new Point(3, 7); Assert.AreEqual(315, PointCalculator.CalculateAngle(p1, p2).Degree); }
private void DrawMainObjectPath(ProjectedPositionCalculator ppCalc) { var position = _objects.MainObject.Location; var speed = _objects.MainObject.Speed; var mass = _objects.MainObject.Mass; for (var i = 0; i < 300; i++) { var forces = new Force(Angle.Zero, 0); foreach (var planet in _objects.Terrains) { var distance = PointCalculator.Distance(position, planet.Location); var angle = PointCalculator.CalculateAngle(position, planet.Location); forces += GravityCalculator.CalculateGravity(mass, planet.Mass, distance, angle); } var acceleration = forces.GetAcceleration(mass); speed += acceleration.GetSpeed(new TimeSpan(0, 0, 0, 10)); if (speed.Value > 50000) { break; } var flownDistance = speed.GetDistance(new TimeSpan(0, 0, 0, 10)).CalculateXAndY(); position.X += (float)flownDistance.X; position.Y += (float)flownDistance.Y; var projectedPosition = ppCalc.ProjectPoint(position); _graphicsBuffer.Graphics.FillRectangle(new SolidBrush(Color.White), projectedPosition.X, projectedPosition.Y, 1, 1); } }
public void DistanceCalculatedCorrectly5() { var p1 = new PointF(0, 0); var p2 = new Point(2, 0); Assert.AreEqual(2, PointCalculator.Distance(p1, p2), 0.1); }
public void VectorXAndYCalculatedCorrectly1() { var v = new Vector(Angle.FromDegrees(0), 100); Assert.AreEqual(0, PointCalculator.GetVectorX(v)); Assert.AreEqual(100, PointCalculator.GetVectorY(v)); }
public void DistanceCalculatedCorrectly2() { var p1 = new PointF(10, 8); var p2 = new Point(13, 4); Assert.AreEqual(5, PointCalculator.Distance(p1, p2), 0.1); }
public void TestCalculatePointsForTotalMatchesCorrect(int matchesWon, int expectedResult) { PointCalculator pointCalc = new PointCalculator(); int actualResult = pointCalc.CalculatePointsForTotalMatchesCorrect(matchesWon); Assert.Equal(expectedResult, actualResult); }
public void Tick(object s, EventArgs e) { foreach (var movingObject in _objects.Rockets) { movingObject.DragForces = new List <Force>(); movingObject.GravityForces = new List <Force>(); foreach (var gravityObject in _objects.Terrains) { var distance = PointCalculator.Distance(movingObject.Location, gravityObject.Location); var angle = PointCalculator.CalculateAngle(movingObject.Location, gravityObject.Location); var force = GravityCalculator.CalculateGravity(movingObject.Mass, gravityObject.Mass, distance, angle); movingObject.GravityForces.Add(force); var altitude = distance - gravityObject.Diameter; if (altitude < 100000) { // Drag Relevant var rocketForceAngle = movingObject._angle; var dragAngle = Angle.FromDegrees(movingObject.Speed.Angle.Degree + 180); var speedDirectionDiff = Angle.FromDegrees(rocketForceAngle.Degree - movingObject.Speed.Angle.Degree); var cd = movingObject.Drag.GetDragCoefficient(speedDirectionDiff); var a = movingObject.Drag.GetArea(speedDirectionDiff); var p = AtmosphereCalculator.CalculateAirDensityAtAltitude(altitude); var dragForce = DragCalculator.CalculateDrag(dragAngle, cd, p, movingObject.Speed, a); movingObject.DragForces.Add(dragForce); } } movingObject.Tick(); } }
/// <summary> /// Creates provider for specified eliptic curve technology. /// </summary> /// <param name="curve"></param> public ECProvider(ElipticCurve curve) { this.curve = curve; calculator = new PointCalculator(curve); serialiser = new PointSerialiser(curve); rnd = new RandomBigNumbers(); }
public void TestRoundTierGetsCalculatedCorrectly(int roundNumber, int result) { Tournament tour = new Tournament() { Id = 1, Name = "Tournament", NumberOfRounds = 14, IsDone = false, Rounds = new List <Round>(), Participants = new List <UserTour>() }; Round round = new Round() { Id = 1, RoundNumber = roundNumber, TournamentId = 1, Tournament = tour, TotalGoals = 0, Matches = new List <Match>() }; PointCalculator pointCalc = new PointCalculator(); int roundTier = pointCalc.CalculateRoundTier(round, tour); Assert.True(roundTier == result); }
static void Main(string[] args) { PointsProcessor testPoint = new PointsProcessor(@"C:\Users\robin\Documents\code\points\points.txt"); PointCalculator testPoints = new PointCalculator(); EnvelopeCalculator testEnvelope = new EnvelopeCalculator(); //testPoint.ReadPointSetFromFile(); Point first = new Point(1, 1); Point second = new Point(1, 3); Point third = new Point(4, 5); Point fourth = new Point(7, 8); Point fifth = new Point(10, 2); Point sixth = new Point(7, 12); Point seventh = new Point(1, 4); Point[] mewArr = new Point[] { first, second, third, fourth, fifth, sixth }; // Envelope envelope = testPoints.FindEnvelope(mewArr); // bool answer = testEnvelope.ContainsPoint(fourth, envelope); // testPoint.WritePointToFile(mewArr); //double dist = testPoints.DistBtwPoints(first, fourth); Point closest = testPoints.ClosestPoint(mewArr, seventh); }
public void TestCalculateRatingBonus(int rating, int points) { PointCalculator pointCalc = new PointCalculator(); int expectedResult = points; int actualResult = pointCalc.CalculateRatingBonus(rating); Assert.Equal(expectedResult, actualResult); }
public void CalculatePoints_Test(int killedEnemies, int killedVillagers, int multiplicator, int expectedPoints) { PointCalculator pointCalculator = new PointCalculator(); int points = pointCalculator.CalculatePoints(killedEnemies, killedVillagers, multiplicator); Assert.That(points, Is.EqualTo(expectedPoints)); }
public void initialize() { GameObject tempObject = GameObject.Find("Targets"); PointCalculator calculator = tempObject.GetComponent <PointCalculator>(); boardSize = calculator.size; blueFinalScore = 0; redFinalScore = 0; holder = GameObject.Find("ThrowableInstanceHolder"); }
public PixelCollection Draw(PixelCollection pixels, IList <Point> drawingPoints, DrawingItemProperties properties) { Point center = PointCalculator.GetCenter(drawingPoints.First(), drawingPoints.Last()); Point topCenter = new Point(center.X, drawingPoints.First().Y); Point bottomCenter = new Point(center.X, drawingPoints.Last().Y); double radius = PointCalculator.GetLenght(topCenter, bottomCenter) / 2; return(BresenhamCircle(pixels, center, radius, properties.Color)); }
/// <summary> /// Sets the fishlines to a normal of custom version. /// </summary> /// <param name="p1">First point.</param> /// <param name="p2">Second point.</param> /// <param name="customFishLines">Draw custom fishlines</param> public void setFishLines(PointF p1, PointF p2, bool customFishLines) { if (customFishLines) { double pixelsPerCentimeter = ImageHandler.Instance.getPixelsPerCentimeter(); fishLines = PointCalculator.getFishLine(getRealPInvert(p1), getRealPInvert(p2), pixelsPerCentimeter); } else { fishLines = PointCalculator.getFishLine(getRealPInvert(p1), getRealPInvert(p2), false, new PointF()); } }
private bool RocketCollidedWithPlanet(Terrain.Terrain planet, List <PointF> corners) { foreach (var corner in corners) { if (PointCalculator.Distance(corner, planet.Location) < planet.Diameter) { return(true); } } return(false); }
public void TestCalculatePointsForTotalGoalsThisRound(int goalsGuessedByUser, int expectedResult) { Round round = new Round { Id = 1, RoundNumber = 1, TotalGoals = 20 }; PointCalculator pointCalc = new PointCalculator(); int actualResult = pointCalc.CalculatePointsForTotalGoalsThisRound(round, goalsGuessedByUser); Assert.Equal(expectedResult, actualResult); }
public static void Clear() { lastDataDiff = 0f; diffCollected = false; touched = false; Data.Clear(); if (CopyData != null) { CopyData.Clear(); } DiffData.Clear(); reportObjectivesData = null; pointCalculator = null; }
public void DisplayLocation(Rocket rocket) { var distance = 0F; foreach (var planet in _objects.Terrains) { var newDistance = PointCalculator.Distance(rocket.Location, planet.Location); if (newDistance > distance) { distance = newDistance - (float)planet.Diameter; } } lblLocClosestVal.Text = Decimalpoints.Add(Math.Round(distance)) + " m"; lblLocAngleVal.Text = Math.Round(rocket._angle.Degree - ((rocket._angle.Degree > 180) ? 360 : 0), 1) + "°"; lblLocCoordsVal.Text = Decimalpoints.Add(Math.Round(rocket.Location.X)) + " | " + Decimalpoints.Add(Math.Round(rocket.Location.Y)); _screen.Color = CalcColor(distance); }
/// <summary> /// Returns a list of points that intersect between the fishlines and a given line. /// </summary> /// <param name="p1">Point 1 of a line.</param> /// <param name="p2">Point 2 of a line.</param> /// <param name="lineMatch">Value to set a matched line to</param> /// <returns></returns> public List <PointF> getMatching(PointF p1, PointF p2, bool lineMatch) { List <PointF> matching = new List <PointF>(); double radius = 5; foreach (Line line in DrawHandler.Instance.getFishLines()) { PointF intersection = PointCalculator.getIntersection(p2, p1, line.getPoint(0), line.getPoint(1)); if (intersection.X != 0) { matching.Add(new PointF((float)(intersection.X - radius / 2.0), (float)(intersection.Y - radius / 2.0))); line.setMatched(lineMatch); } } return(matching); }
public static Vector operator +(Vector v1, Vector v2) { var x = PointCalculator.GetVectorX(v1) + PointCalculator.GetVectorX(v2); var y = PointCalculator.GetVectorY(v1) + PointCalculator.GetVectorY(v2); var point = new PointF((float)x, (float)y); var resultingValue = PointCalculator.Distance(new PointF(0, 0), point); var resultingAngle = PointCalculator.CalculateAngle(new PointF(0, 0), point); if (resultingValue < 0.0001) { resultingAngle = Angle.Zero; } return(new Vector(resultingAngle, resultingValue)); }
/// <summary> /// 新しいベクトル描画マネージャを作成します。 /// </summary> /// <param name="g">グラフィックデバイス</param> /// <param name="arrow">矢印の設定オブジェクト</param> /// <param name="MaxValue">データの最大値</param> public ArrowDrawer( Graphics g, VectorSetting arrow, double MaxValue, double MinValue ) { this.Arrow = arrow; this.G = g; this.maxValue = MaxValue; this.minValue = MinValue; this.refValue = arrow.ReferredLength; this.unitLength = 500/20.0; this.magnitude = this.Arrow.Length/100.0/this.refValue*this.unitLength*2; this.tipMagnitude = this.Arrow.TipLength/100.0*this.magnitude; this.halfTipAngle = arrow.TipAngle/180.0*Math.PI/2.0; this.tan_halfTipAngle = Math.Tan( this.halfTipAngle ); this.linePen = new Pen( arrow.LineColor, arrow.LineWidth ); this.innerBrush = new SolidBrush( arrow.InnerColor ); switch( arrow.TipType ) { case TipType.FillTriangle: this.arrowDrawer = this.drawTrAnglArrow; break; case TipType.LineTip: this.arrowDrawer = this.drawLineArrow; break; default: throw new NotImplementedException(); } if( arrow.FixTipSize ) { this.pointCalculator = this.calcFixPoints; } else { this.pointCalculator = this.calcVarPoints; } if( arrow.Colorful ) { this.lineColorSetter = this.setColorfulColor; this.innerColorSetter = this.setColorfulColor; } else { this.lineColorSetter = this.setFixedPenColor; this.innerColorSetter = this.setFixedBrushColor; } }
// Use this for initialization void Start() { score = 0; if (GetComponent <CircleCollider2D>() != null) { coll = GetComponent <CircleCollider2D>(); } else { coll = GetComponent <PolygonCollider2D>(); } team = GetComponent <Team>().team; GameObject allTargets = GameObject.Find("Targets"); PointCalculator rightTarget = allTargets.GetComponent <PointCalculator>(); comparePoints = rightTarget.finalPoints; }
public void TestCalculateTips() { User user1 = new User() { Id = 1, Firstname = "Karl", Lastname = "Bielsen", IsAdmin = false, Email = "*****@*****.**", Tips = new List <UserMatch>(), Tournaments = new List <UserTour>(), RoundPoints = new List <UserRound>() }; Match match1 = new Match() { Id = 1, HomeTeam = "Home", HomeScore = 3, GuestTeam = "Guest", GuestScore = 1, StartDate = new DateTime(2019, 11, 27), RoundId = 1, Tips = new List <UserMatch>() }; UserMatch tips1 = new UserMatch() { Id = 1, User = user1, UserId = 1, Match = match1, MatchId = 1, HomeTip = 3, GuestTip = 1, Rating = 1 }; user1.Tips.Add(tips1); PointCalculator pointCalc = new PointCalculator(); int expectedResult = 38; int actualResult = pointCalc.CalculateTips(tips1, match1); Assert.Equal(expectedResult, actualResult); }
public void DisplayLocation(Rocket rocket) { var distance = float.MaxValue; var name = ""; foreach (var planet in _objects.Terrains) { var newDistance = PointCalculator.Distance(rocket.Location, planet.Location); if (newDistance < distance) { distance = newDistance - (float)planet.Diameter; name = planet.Name; } } lblLocClosestVal.Text = DecimalPoints.Add(distance, 0) + " m"; lblNameClosestVal.Text = name; lblLocAngleVal.Text = Math.Round(rocket._angle.Degree - ((rocket._angle.Degree > 180) ? 360 : 0), 1) + "°"; lblLocCoordsVal.Text = DecimalPoints.Add(rocket.Location.X, 0) + " | " + DecimalPoints.Add(rocket.Location.Y, 0); _screen.Color = CalcColor(distance); }
/// <summary> /// UV情報を利用しMesh上に等間隔に点を配置 /// </summary> /// <param name="data"></param> /// <param name="baseMesh"></param> /// <param name="evenIntervalOnUV"></param> /// <param name="uvType"></param> public Data.PointData BuildPointOnMesh(Mesh baseMesh, List <Vector2> evenIntervalOnUV, UVType uvType) { var data = ScriptableObject.CreateInstance <Data.PointData>(); var result = new List <Vector3>(); var normals = new List <Vector3>(); Vector2[] uvs; if (uvType == UVType.UV) { uvs = baseMesh.uv; } else { uvs = baseMesh.uv2; } Vector3[] meshVertices = baseMesh.vertices; for (int subMesh = 0; subMesh < baseMesh.subMeshCount; subMesh++) { int[] submeshTriangles = baseMesh.GetTriangles(subMesh); for (int i = 0; i < submeshTriangles.Length; i += 3) { var calcedUvs = PointCalculator.GetIntermediatePoint(evenIntervalOnUV, i, uvs, submeshTriangles); var meshed = PointCalculator.GetPointsOnMeshSurface(calcedUvs, i, meshVertices, submeshTriangles); var surfNormal = PointCalculator.GetSurfaceNormal(i, meshVertices, submeshTriangles); foreach (var m in meshed) { normals.Add(surfNormal); } result.AddRange(meshed); } } data.points = result; data.normals = normals; return(data); }
/// <summary> /// Initializes variables. /// </summary> public override void Init() { // bounding box _boundingBox = new BoundingBox(); _boundingBox.UpdateCallbacks += OnBoundingBoxUpdate; //get drone position from Calculator _pointCalc = new PointCalculator(); // read shaders from files _pointCloud = new PointCloud(RC, _boundingBox); _voxelSpace = new VoxelSpace(RC, _boundingBox); _dronePath = new DronePath(RC); //Zoom Value _zoom = 120; // stream point cloud from text file ///* //AssetReader.OnNewPointCallbacks += OnNewPointAdded; //AssetReader.ReadFromAsset("PointCloud_IPM.txt"); //*/ //stream from binary via udp PointCloudReader.OnNewPointCallbacks += OnNewPointAdded; PointCloudReader.OnDronePositionCallbacks += OnDronePositionAdded; // stream point cloud via udp //UDPReceiver.OnNewPointCallbacks += OnNewPointAdded; // UDPReceiver.OnDronePositionCallbacks += OnDronePositionAdded; //UDPReceiver.StreamFrom(UDP_PORT); // Set the clear color for the backbuffer RC.ClearColor = new float4(0.95f, 0.95f, 0.95f, 1); }