public void Receive2Inputs_Update_SpeedAndDirectionIsNaN() { //Create fake Plane with Invalid IPlane invalidSpeedPlane = Substitute.For <IPlane>(); invalidSpeedPlane.Tag.Returns("TEST123"); invalidSpeedPlane.XCoordinate.Returns(10000); invalidSpeedPlane.YCoordinate.Returns(10000); invalidSpeedPlane.LastUpdate.Returns(CorrectDateTime); invalidSpeedPlane.Speed.Returns(Double.NaN); //Create fake Plane with Invalid Direction IPlane invalidDirectionPlane = Substitute.For <IPlane>(); invalidDirectionPlane.Tag.Returns("TEST321"); invalidDirectionPlane.XCoordinate.Returns(10000); invalidDirectionPlane.YCoordinate.Returns(10000); invalidDirectionPlane.LastUpdate.Returns(CorrectDateTime); invalidDirectionPlane.Direction.Returns(Double.NaN); List <IPlane> planeWithNaNSpeed = new List <IPlane> { invalidSpeedPlane, invalidDirectionPlane }; //No planes were added to EmptyPlaneList because all planes that was to be added were invalid. List <IPlane> emptyPlaneList = uut.GetCompletePlanes(planeWithNaNSpeed); Assert.IsEmpty(emptyPlaneList); }
public void Add(IPlane plane) { if (plane != null) { planes.Add(plane); } }
ExpVector[] GetPointsExp(IPlane plane) { var p = new ExpVector[4]; if (HasEntitiesOfType(IEntityType.Point, 4)) { for (int i = 0; i < 4; i++) { p[i] = GetEntityOfType(IEntityType.Point, i).GetPointAtInPlane(0, plane); } } else if (HasEntitiesOfType(IEntityType.Line, 2)) { var l0 = GetEntityOfType(IEntityType.Line, 0); p[0] = l0.GetPointAtInPlane(0, plane); p[1] = l0.GetPointAtInPlane(1, plane); var l1 = GetEntityOfType(IEntityType.Line, 1); p[2] = l1.GetPointAtInPlane(0, plane); p[3] = l1.GetPointAtInPlane(1, plane); } else if (HasEntitiesOfType(IEntityType.Arc, 1)) { var arc = GetEntityOfType(IEntityType.Arc, 0); p[0] = arc.GetPointAtInPlane(0, plane); p[1] = arc.GetPointAtInPlane(2, plane); p[2] = arc.GetPointAtInPlane(2, plane); p[3] = arc.GetPointAtInPlane(1, plane); } return(p); }
public void Plane_OK() { Image image = Utils.Utils.GetImageResource <Terrain>("Landscape.Terrains.Grass.png"); IPlane plane = PlaneFactory.Create(false, new Vbo() { Position = new Vector3(-1, 0, -1), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 0) }, new Vbo() { Position = new Vector3(-1, 0, 1), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1) }, new Vbo() { Position = new Vector3(1, 0, 1), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1) }, new Vbo() { Position = new Vector3(1, 0, -1), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1) }, image, OpenTK.Graphics.OpenGL.TextureWrapMode.Clamp); Assert.AreEqual(2, plane.Width, "Plane Width"); Assert.AreEqual(0, plane.Height, "Plane Height"); Assert.AreEqual(2, plane.Depth, "Plane Depth"); }
public static IMesh Skew(IMesh mesh, IPlane plane = default, IVector3D skewDirection = default, double skewFactor = 1.0) { IMesh dM = mesh.DeepCopy(); if (plane == default) { plane = IPlane.WorldXY; } if (skewDirection == default) { skewDirection = IVector3D.UnitZ; } IPoint3D pt; double d; foreach (int vK in dM.VerticesKeys) { pt = dM.GetVertexWithKey(vK).Position; d = plane.DistanceToPlane(pt); if (d > 0) { pt += IVector3D.Mult(skewDirection, d * skewFactor); } dM.SetVertexPosition(vK, pt); } dM.UpdateGraphics(); return(dM); }
public void AllowLanding(IPlane plane) { if (plane == null) { return; } IFlightDatabase database = FlightDatabase.Instance; //Nalazimo sve letove koji slecu na aerodrom vezan za ovu FlightControl-u //Ako nema jednog leta medju njima koji ima zadati avion(plane) baca se izuzetak List <IFlight> flights = database.FindByDestAirport(Airport); IFlight theFlight = null; foreach (IFlight flight in flights) { if (flight.GetPlane() == plane) { theFlight = flight; } } if (theFlight != null) { List <ITicket> tickets = theFlight.GetTickets(); foreach (ITicket ticket in tickets) { ticket.SetPassenger(null); } } else { throw new PlaneCanNotLandException("Avion ne slece na taj aerodrom"); } plane.Status = Status.FINISHED; //Avion je sleteo plane.ClearPassenger(); //brisu se putnicima karte }
public bool Update(IPlane oldPlane) { // Do not update if tags doesn't match if (this.Tag != oldPlane.Tag) { return(false); } // Can't update with a old plane record if (this.LastUpdate < oldPlane.LastUpdate) { return(false); } // Calculate direction _direction = Calculator.GetDirection2D(oldPlane.XCoordinate, oldPlane.YCoordinate, XCoordinate, YCoordinate); try { // Calculate speed _speed = Calculator.GetSpeed(oldPlane.XCoordinate, oldPlane.YCoordinate, oldPlane.LastUpdate, XCoordinate, YCoordinate, LastUpdate ); } catch (Exception e) { //Console.WriteLine( e ); return(false); } _lastUpdate = oldPlane.LastUpdate; return(true); }
public PlaneController(IPlane Planes, UserManager <AuthUser> userManager, SignInManager <AuthUser> signManager, RoleManager <ApplicationRole> roleManager) { _planes = Planes; _userManager = userManager; _signManager = signManager; _roleManager = roleManager; }
/// <summary> /// Initializes a new instance of the BoardingPass class, for a plane of a given size and with a known path to the seat /// </summary> /// <param name="plane">The plane to which this boarding pass applies</param> /// <param name="seatPath">The path to the boarding pass holder's seat</param> public BoardingPass(IPlane plane, string seatPath) { Plane = plane; SeatPath = seatPath; FindSeat(); }
public void SetUp() { fakeCheckPlanes = Substitute.For <ICheckPlanes>(); uut = new Airspace(fakeCheckPlanes); fakePlanes = new List <IPlane>(); fakeILeaveEvent = Substitute.For <ILeaveEvent>(); receivedData = new LeaveEventArgs.Msg(); nEventsReceived = 0; CheckPlanes.ListOfTags = new List <string>(); time1 = new DateTime(2010, 10, 10, 00, 01, 00); fakePlane = new Plane(); fakePlane.XCoordinate = 20000; fakePlane.YCoordinate = 42000; fakePlane.Altitude = 900; fakePlane.Tag = "MarkusFriis"; fakePlanes.Add(fakePlane); fakeILeaveEvent.RaisedLeaveEvent += (o, args) => { receivedData = args.Message; ++nEventsReceived; }; }
/// <summary> /// Constructs an axis. /// </summary> /// <param name="axis">The axis.</param> public void ApplyStyleToAxis(IPlane <TDrawingContext> axis) { foreach (var rule in AxisBuilder) { rule(axis); } }
public SeperationsEventArgs(IPlane _plane1, IPlane _plane2, string _timestamp) { Message = new Msg(); Message.plane1 = _plane1; Message.plane2 = _plane2; Message.timestamp = _timestamp; }
public static ExpVector GetLineP0(this IEntity entity, IPlane plane) { var points = entity.points.GetEnumerator(); points.MoveNext(); return(plane.ToFrom(points.Current, entity.plane)); }
[TestCase(1000, 1000, 500, 1000, 1000, 800)] //Planes Z-coordinates are just far enough to not trig Separation. public void PlanesNotTooClose(int x1, int y1, int z1, int x2, int y2, int z2) { // Create two fake planes with the given parameters IPlane plane1 = Substitute.For <IPlane>(); plane1.Tag.Returns("AAA"); plane1.XCoordinate.Returns(x1); plane1.YCoordinate.Returns(y1); plane1.Altitude.Returns(z1); plane1.LastUpdate.Returns(DateTime.Today); IPlane plane2 = Substitute.For <IPlane>(); plane2.Tag.Returns("BBB"); plane2.XCoordinate.Returns(x2); plane2.YCoordinate.Returns(y2); plane2.Altitude.Returns(z2); plane2.LastUpdate.Returns(DateTime.Today); // Add planes to a list List <IPlane> testList = new List <IPlane> { plane1, plane2 }; List <List <IPlane> > ReturnList = new List <List <IPlane> >(); ReturnList = uut.CheckPlanes(testList); // If return list is empty that means no planes were violating the rule Assert.IsEmpty(ReturnList); }
public ICollection <IPlane> CreateAirlinePlanes() { List <IPlane> planes = new List <IPlane>(); try { var files = Directory.EnumerateFiles(airlineDirectory, filePattern); foreach (var file in files) { string[] content = File.ReadAllLines(file); if (content.Length > 0) { IPlane plane = CreatePlane(content); if (plane != null) { planes.Add(plane); } } } } catch (Exception e) { Console.WriteLine(e.Message); } return(planes); }
public static ExpVector NormalAtInPlane(this IEntity self, Exp t, IPlane plane) { if (self.plane != null) { var tang = self.TangentAt(t); if (tang == null) { return(null); } var n = ExpVector.Cross(tang, Vector3.forward); if (plane == self.plane) { return(n); } return(plane.DirToFrom(n, self.plane)); } Param p = new Param("pOn"); var pt = self.PointOn(p); var result = new ExpVector(pt.x.Deriv(p).Deriv(p), pt.y.Deriv(p).Deriv(p), pt.z.Deriv(p).Deriv(p)); result.x.Substitute(p, t); result.y.Substitute(p, t); result.z.Substitute(p, t); if (plane == null) { return(result); } return(plane.DirToPlane(result)); }
public void CreateMyJet() { if (MyPlane == null) { MyPlane = new MyJet(new Point(180, 530)); } }
public virtual bool IsHitTarget(IPlane plane) { Rectangle rectangle = new Rectangle(Position, BulletSize); Rectangle target = new Rectangle(plane.GetPosition(), plane.GetSize()); return(rectangle.IntersectsWith(target)); }
public static ExpVector OffsetAtInPlane(this IEntity e, Exp t, Exp offset, IPlane plane) { if (plane == e.plane) { return(e.PointOn(t) + e.NormalAt(t).Normalized() * offset); } return(e.PointOnInPlane(t, plane) + e.NormalAtInPlane(t, plane).Normalized() * offset); }
ExpVector GetPointInPlane(int index, IPlane plane) { if (HasEntitiesOfType(IEntityType.Point, 2)) { return(GetEntityOfType(IEntityType.Point, index).PointExpInPlane(plane)); } return(GetEntityOfType(IEntityType.Line, 0).GetPointAtInPlane(index, plane)); }
public bool Equals(IPlane other) { if (Name == other.Name && Producer.Equals(other.Producer)) { return(true); } return(false); }
public static ExpVector TangentAtInPlane(this IEntity entity, Exp t, IPlane plane) { if (plane == entity.plane) { return(entity.TangentAt(t)); } return(plane.DirToFrom(entity.TangentAt(t), entity.plane)); }
public static ExpVector PointOnInPlane(this IEntity entity, Exp t, IPlane plane) { if (plane == entity.plane) { return(entity.PointOn(t)); } return(plane.ToFrom(entity.PointOn(t), entity.plane)); }
public static ExpVector DirFromPlane(this IPlane plane, ExpVector dir) { if (plane == null) { return(dir); } return((ExpVector)plane.u * dir.x + (ExpVector)plane.v * dir.y + (ExpVector)plane.n * dir.z); }
public static Vector3 DirFromPlane(this IPlane plane, Vector3 dir) { if (plane == null) { return(dir); } return(plane.u * dir.x + plane.v * dir.y + plane.n * dir.z); }
public static ExpVector FromPlane(this IPlane plane, ExpVector pt) { if (plane == null) { return(pt); } return(plane.o + (ExpVector)plane.u * pt.x + (ExpVector)plane.v * pt.y + (ExpVector)plane.n * pt.z); }
public static Vector3 FromPlane(this IPlane plane, Vector3 pt) { if (plane == null) { return(pt); } return(plane.o + plane.u * pt.x + plane.v * pt.y + plane.n * pt.z); }
public static ExpVector PointExpInPlane(this IEntity entity, IPlane plane) { var it = entity.PointsInPlane(plane).GetEnumerator(); it.MoveNext(); return(it.Current); //return entity.PointsInPlane(plane).Single(); }
public void AnimateToPlane(IPlane plane) { srcRot = camera.transform.rotation; dstRot = plane.GetRotation(); srcPos = camera.transform.position; dstPos = plane.o; phase = 0.0f; }
public static Matrix4x4 GetTransform(this IPlane plane) { if (plane == null) { return(Matrix4x4.identity); } return(UnityExt.Basis(plane.u, plane.v, plane.n, plane.o)); }
public bool Remove(IPlane item) { return _fleet.Remove(item); }
public void BuyPlane(IPlane plain) { airline.Add(plain); }
public void CopyTo(IPlane[] array, int arrayIndex) { _fleet.CopyTo(array, arrayIndex); }
/// <summary> /// Animates to look at the given plane. /// </summary> public void AnimateTo(IPlane plane) { Vector center, position, upVec; GetPlaneVectors(plane, out center, out position, out upVec); AnimateTo(center, position, upVec); }
/// <summary> /// Gets the intersection of the hitline with a plane. /// </summary> /// <param name="plane"></param> /// <returns></returns> /// <remarks>Uses the formula found in the Wikipedia article /// (http://en.wikipedia.org/wiki/Line-plane_intersection).</remarks> public Vector GetIntersection(IPlane plane) { double d = plane.Origin.Dot(plane.Normal); double t = (d - Front.Dot(plane.Normal)) / (Back - Front).Dot(plane.Normal); return (Back - Front) * t + Front; }
public void Add(IPlane plane) { Planes.Add(plane); }
public void Remove(IPlane itemPlane) { Planes.Remove(itemPlane); }
public Adapter(IPlane plane) { this.plane = plane; }
public void Add(IPlane item) { _fleet.Add(item); }
public bool Contains(IPlane item) { return _fleet.Contains(item); }
public int CompareTo(IPlane other) { return this.Range.CompareTo(other.Range); }
/// <summary> /// Gets the vector needed to look at a plane. /// </summary> public void GetPlaneVectors(IPlane plane, out Vector centerOut, out Vector posOut, out Vector upVecOut) { Bounds bounds = _scene.RenderList.Bounds; // determine the distance needed to view all renderables double dist = 0; if (_scene.RenderList.ActorCount > 0 && bounds.IsSet) dist = bounds.MaxWidth / (fov * 0.5).Tan(); else dist = 2 / (fov * 0.5).Tan(); centerOut = plane.Origin; posOut = centerOut + plane.Normal.Normalize() * dist * 0.8; if (plane.Normal[1] == 0 && plane.Normal[2] == 0) // the normal is in the Y-Z axis upVecOut = new Vector(0.0, 1.0, 0.0); else // the plane is not in the Y-Z axis upVecOut = new Vector(1.0, 0.0, 0.0); }
/// <summary> /// Forces the camera to look squarely at a plane. /// </summary> /// <param name="plane"></param> public void LookAt(IPlane plane) { GetPlaneVectors(plane, out _center, out _position, out _upVec); RecomputeUpVector(); // _scene.Resize(); _scene.OnDirectionChanged(); }