/// <summary>
        /// Creates a new instance of <see cref="LinePointUVAndSegment"/> based on the starting point <paramref name="linePoint"/> and filling in segment information based on the <paramref name="otherPoint"/>.
        /// </summary>
        /// <param name="linePoint">The line point which is the start of the line segment.</param>
        /// <param name="otherPoint">The other point in the line segment.</param>
        public LinePointUVAndSegment(LinePointUV linePoint, Vector2 otherPoint)
        {
            Parameter  = linePoint.Parameter;
            Point      = linePoint.Point;
            UV         = linePoint.UV;
            OtherPoint = otherPoint;
            var segmentVector = otherPoint - linePoint.Point;

            SegmentTangent = segmentVector.normalized;
            SegmentNormal  = NormalUtil.NormalFromTangent(SegmentTangent);
            SegmentLength  = segmentVector.magnitude;
        }
Пример #2
0
        /// <summary>
        /// Get an intersection point along an extruded segment, due to a neighbouring segment, given the extrusion amount and fraction along the segment where the intersection occurs.
        /// </summary>
        /// <param name="pointVector"></param>
        /// <param name="segmentDirection">Segment direction vector</param>
        /// <param name="extrusionMagnitudeFractionAlongSegment">Fraction of extrusion distance along the segment</param>
        /// <param name="extrusionAmount">The extrusion amount</param>
        internal static Vector2 GetExtrudedSegmentNeighbouringIntersectionPoint(Vector2 pointVector, Vector2 segmentDirection, double extrusionMagnitudeFractionAlongSegment, float extrusionAmount)
        {
            var normal = NormalUtil.NormalFromTangent(segmentDirection);

            return(pointVector + extrusionAmount * normal + Mathf.Abs(extrusionAmount) * segmentDirection * (float)extrusionMagnitudeFractionAlongSegment);
        }