/// <summary> /// Creates an instance of <see cref="LinePointUVAndSegment"/> with <see cref="Parameter"/>, <see cref="Point"/>, and <see cref="UV"/> values from <paramref name="linePoint"/>, but with all other public fields explicitly specified. /// </summary> /// <param name="linePoint">The line point used for <see cref="Parameter"/>, <see cref="Point"/>, and <see cref="UV"/> values.</param> /// <param name="otherPoint">The other point in the segment.</param> /// <param name="tangent">The specified tangent vector of the segment.</param> /// <param name="normal">The specified normal vector of the segment.</param> /// <param name="length">The specified length of the segment.</param> public LinePointUVAndSegment(LinePointUV linePoint, Vector2 otherPoint, Vector2 tangent, Vector2 normal, float length) { Parameter = linePoint.Parameter; Point = linePoint.Point; UV = linePoint.UV; OtherPoint = otherPoint; SegmentTangent = tangent; SegmentNormal = normal; SegmentLength = length; }
/// <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; }
/// <summary> Gets the position of a <see cref="LinePointUV"/>.</summary> /// <param name="linePointUv">The <see cref="LinePointUV"/>.</param> private static Vector2 GetVector(LinePointUV linePointUv) { return(linePointUv.Point); }
/// <summary> /// Average with another <see cref="LinePointUV"/>. /// </summary> /// <param name="other">The other point.</param> /// <param name="fractionOfOther">The fractional weight of the other point in the average.</param> public LinePointUV AverageWith(LinePointUV other, float fractionOfOther) { float fractionOfThis = 1f - fractionOfOther; return(new LinePointUV(fractionOfThis * Parameter + fractionOfOther * other.Parameter, fractionOfThis * Point + fractionOfOther * other.Point, fractionOfThis * UV + fractionOfOther * other.UV)); }
/// <summary> Gets the average of two <see cref="LinePointUV"/>.</summary> /// <param name="firstVector">The first vector</param> /// <param name="secondVector">The second vector</param> /// <param name="fractionOfSecond"> The weight of the second vector in the average</param> private static LinePointUV GetAverage(LinePointUV firstVector, LinePointUV secondVector, float fractionOfSecond) { return(firstVector.AverageWith(secondVector, fractionOfSecond)); }
/// <summary> Gets the average of two <see cref="ExtrudedPointUV"/>, not really caring about the line point segment indexes for the purposes of ClosestPointAlongSegmentwiseLine.</summary> /// <param name="firstVector">The first vector</param> /// <param name="secondVector">The second vector</param> /// <param name="fractionOfSecond"> The weight of the second vector in the average</param> private static ExtrudedPointUV GetAverage(ExtrudedPointUV firstVector, ExtrudedPointUV secondVector, float fractionOfSecond) { var averagedLinePoint = new LinePointUV(firstVector).AverageWith(new LinePointUV(secondVector), fractionOfSecond); return(new ExtrudedPointUV(averagedLinePoint, firstVector.LinePointSegmentIndex, firstVector.LinePointSegmentIndex2)); }
/// <summary> /// Creates and instance of <see cref="SegmentwiseExtrudedPointListUV"/> from a <see cref="LinePointUV"/> Point and UV, as well as a normal vector, extrusion amount, line Parameter, and index used for <see cref="LinePointSegmentIndex"/> and <see cref="LinePointSegmentIndex2"/>. /// </summary> /// <param name="linePoint">The <see cref="LinePointUV>"/> line point instance, with Point, and UV values.</param> /// <param name="parameter">The point's parameter along the line (from a line parametrization loosely like arclength).</param> /// <param name="normal">The normal vector used in determining the extruded point's location.</param> /// <param name="extrusionAmount">The extrusion amount.</param> /// <param name="lineSegmentIndex">The index used for <see cref="LinePointSegmentIndex"/> and <see cref="LinePointSegmentIndex2"/></param> public ExtrudedPointUV(LinePointUV linePoint, float parameter, Vector2 normal, float extrusionAmount, int lineSegmentIndex) : this(parameter, linePoint.Point + normal * extrusionAmount, linePoint.UV, lineSegmentIndex, lineSegmentIndex) { }
/// <summary> /// Creates an instance of <see cref="SegmentwiseExtrudedPointListUV"/> taking the <see cref="LinePointUV.Parameter"/>, <see cref="LinePointUV.Point"/> and <see cref="LinePointUV.UV"/> values along with the given <see cref="LinePointSegmentIndex"/> and <see cref="LinePointSegmentIndex2"/> values. /// </summary> /// <param name="linePoint">The <see cref="LinePointUV>"/> line point instance, with Parameter, Point, and UV values.</param> /// <param name="linePointSegmentIndex">The index of the original line segment start point that this point is extruded from.</param> /// <param name="linePointSegmentIndex2">he index of another original line segment start point that this point is extruded from (if different from <see cref="LinePointSegmentIndex"/>).</param> public ExtrudedPointUV(LinePointUV linePoint, int linePointSegmentIndex, int linePointSegmentIndex2) : this(linePoint.Parameter, linePoint.Point, linePoint.UV, linePointSegmentIndex, linePointSegmentIndex2) { }
/// <summary> /// Creates a new instance of <see cref="Vector2WithUV"/> with <see cref="Point"/> and <see cref="UV"/> values from a <paramref name="linePointUV"/>. /// </summary> /// <param name="linePointUV">The <see cref="LinePointUV"/> from which to take <see cref="Point"/> and <see cref="UV"/> values.</param> internal Vector2WithUV(LinePointUV linePointUV) : this(linePointUV.Point, linePointUV.UV) { }