Пример #1
0
 // TODO: Helper functions
 /// <summary>Creates a straight track segment from two specified points.</summary>
 /// <param name="pointA">The first point.</param>
 /// <param name="pointB">The second point.</param>
 /// <param name="orientation">The orientation at the first point without factoring in roll. The Z component of this parameter must point from A toward B.</param>
 /// <param name="rollA">The roll at the first point.</param>
 /// <param name="rollB">The roll at the second point.</param>
 /// <param name="segment">Receives the segment on success. The start and end of the segment may be connected to other track segments.</param>
 /// <returns>The success of this operation. This operation fails if the two specified points coincide.</returns>
 public static bool CreateStraightSegmentFromPoints(Math.Vector3 pointA, Math.Vector3 pointB, Math.Orientation3 orientation, double rollA, double rollB, out PhysicalSegment segment)
 {
     if (pointA == pointB) {
         segment = null;
         return false;
     } else {
         double length = OpenBveApi.Math.Vector3.Norm(pointB - pointA);
         StraightSegment straight = new StraightSegment();
         straight.Previous = SegmentConnection.Empty;
         straight.Next = SegmentConnection.Empty;
         straight.Length = length;
         straight.StartingRoll = rollA;
         straight.EndingRoll = rollB;
         straight.Position = pointA;
         straight.Orientation = orientation;
         segment = straight;
         return true;
     }
 }
Пример #2
0
 /// <summary>Creates track segments from two specified points.</summary>
 /// <param name="pointA">The first point.</param>
 /// <param name="pointB">The second point.</param>
 /// <param name="orientationA">The orientation at the first point.</param>
 /// <param name="orientationB">The orientation at the second point.</param>
 /// <param name="rollA">The roll at the first point.</param>
 /// <param name="rollB">The roll at the second point.</param>
 /// <param name="segments">Receives the segments on success. The start of the first segment and end of the last segment may be connected to other track segments.</param>
 /// <returns>The success of this operation. This operation fails if the two specified points coincide.</returns>
 /// <remarks>This method usually creates two circular segments of equal radius but opposing direction in order to connect the two points while respecting their specified orientations. In special cases, this method will create a single curved segment or a single straight segment.</remarks>
 public static bool CreateCurvedSegmentFromPoints(Math.Vector3 pointA, Math.Vector3 pointB, Math.Orientation3 orientationA, Math.Orientation3 orientationB, double rollA, double rollB, out PhysicalSegment[] segments)
 {
     throw new NotImplementedException();
 }
Пример #3
0
 // constructors
 /// <summary>Creates a new instance of this structure.</summary>
 /// <param name="segment">The physical track segment the point lies on.</param>
 /// <param name="position">The position.</param>
 /// <param name="orientation">The orientation, either with or without factoring in the Roll parameter.</param>
 /// <param name="orientationIncludesRoll">Whether the Orientation has the Roll parameter factored in.</param>
 /// <param name="roll">The roll expressed as an angle.</param>
 public SegmentPoint(PhysicalSegment segment, Math.Vector3 position, Math.Orientation3 orientation, bool orientationIncludesRoll, double roll)
 {
     this.Segment = segment;
     this.Position = position;
     if (orientationIncludesRoll) {
         this.OrientationWithRoll = orientation;
         this.OrientationWithoutRoll = Math.Orientation3.RotateAroundZAxis(orientation, System.Math.Cos(roll), -System.Math.Sin(roll));
     } else {
         this.OrientationWithoutRoll = orientation;
         this.OrientationWithRoll = Math.Orientation3.RotateAroundZAxis(orientation, System.Math.Cos(roll), System.Math.Sin(roll));
     }
     this.Roll = roll;
 }