namespace: CurveArchitect.Utilites
files: BezierCurve.cs, BezierCurve_Point.cs, BezierCurve_Rotation.cs, BezierCurve_Conversion.cs
General
Vector3 GetPosition(List<Segement> segements, float time, bool useLocal = false)
Description:
Calculates the position along a path for a given time (0 - 1), with optional local coordinates.
Returns:
The position at the given time.
Vector3 GetPositionExtended(List<Segement> segements, float curveLength, float time)
Description:
Calculates an extended position on a curve, allowing for extrapolation beyond the start or end points based on the given time (< 0 || > 1).
Returns:
The extrapolated position along the curve's extension line.
Vector3 GetPositionFast(List<Vector3> positionMap, float resolution, float time)
Description:
Quickly retrieves an interpolated position from a pre-mapped list based on time (0 - 1).
Returns:
The interpolated position.
Vector3[] GetNormals(ArchitectCurve d, float timeValue, bool skiprotation = false)
Description:
Generates an array of three orthogonal unit vectors (normals) at a specific point on a curve based on the given time value.
Returns:
An array of three normalized vectors representing the right, up, and forward directions at the specified curve position.
Vector3 GetDirection(List<Segement> segements, float time, bool backwards = false)
Description:
Returns the normalized directional vector of a specified segment in a list of segments, calculated from the segment's anchor point towards its tangent point.
Returns:
The normalized tangent vector at the specified parameter value along the curve.
Vector3 GetTangent(Vector3 a, Vector3 ata, Vector3 btb, Vector3 b, float t)
Description:
Calculates the tangent vector at a specific point along a cubic Bezier curve, defined by four control points.
Returns:
The normalized direction vector of the specified segment.
int GetSegement(List<Segement> segements, float time)
Description:
Determines the index of the segment in a list that corresponds to a given time (0 - 1) value,
Returns:
The index of the segment that aligns with the specified time.
Vector3 GetSegementPosition(List<Segement> segements, int segement, float time, bool useLocal = false)
Description:
Calculates the position on a path segment at a specified time (0 - 1) using cubic interpolation, with options for local or global coordinates.
Returns:
The interpolated position.
float GetSegementTime(int segement, float anchorsCount, float time)
Description:
Computes a time value for a specific segment in a path, adjusting based on the segment's position and the total time (0 - 1)
Returns:
The time value within the specified segment.
Vector3 GetSegementDirection(List<Segement> segements, int segement)
Description:
Calculates the direction vector of a specified segment.
Returns:
The normalized direction vector of the specified segment.
Vector3 CubicLerp(Vector3 a, Vector3 ata, Vector3 btb, Vector3 b, float time)
Description:
Performs a cubic interpolation between four points in 3D space using a Bezier curve approach.
Returns:
Returns the interpolated position along the curve at the specified time (0 - 1).
float GetValidatedTime(float time, bool loop)
Description:
Validates a time value depending on whether the curve is looped or not.
Returns:
The validated time value.
Vector3 GetCenter(List<Segement> segements)
Description:
Calculates the center of a curve.
Returns:
The average position of all anchor points, representing the center of the curve.
void CalculatePositionMap(ArchitectCurve ac)
Description:
Computes and caches positions for an Architect Curve.
void CalculateLengthMap(ArchitectCurve ac)
Description:
Computes and stores a mapping of time values to their corresponding positions along an Architect Curve, ensuring accurate length proportionality.
void CalculateCachedNormals(ArchitectCurve ac)
Description:
Calculates and caches the normals for a dynamic Architect Curve, allowing for consistent orientation adjustments during deformations.
Rotation
Quaternion GetZRotation(Vector3 curveDirection, float fixedTime, List<Segement> segements)
Description:
Calculates a Quaternion representing the Z-axis rotation along a segment of the curve, interpolating based on user-defined anchor rotations.
Returns:
The Quaternion representing the Z-axis rotation at the specified curve segment and time.
float GetZRotationDegrees(List<Segement> segements, float time)
Description:
Computes the interpolated Z-axis rotation in degrees for a specific time along a segmented curve, based on contrast adjustments at anchor points.
Returns:
The Z-axis rotation in degrees, interpolated for the specified time and adjusted for segment contrast.
Point
Vector3 ClosestPointStepByStep(ArchitectCurve d, Vector3 point, float steps, out float time, bool ignoreYAxel, bool useFixedTime)
Description:
Calculates the closest point on an curve to a given point, with options for ignoring the Y-axis and using fixed time.
Returns:
The closest position on the curve.
Vector3 ClosestPoint(ArchitectCurve d, Vector3 point, int precision, out float timeValue, float steps = 5, bool ignoreYAxel = false, bool useFixedTime = false)
Description:
Determines the closest point on an curve to a given point, refining the position iteratively for accuracy. Optionally ignores the Y-axis and utilizes fixed-time mapping.
Returns:
The closest position on the curve.
Conversion
float ToggleTimeFixedTime(List<float> lengthMap, float lengthMapStep, float timeValue, bool loop)
Description:
Adjusts a time value based on a length map to correct for non-linear distributions in Bezier curve lengths, suitable for looping and non-looping scenarios.
Returns:
Fixed time.
Vector3 CurvePositionToWorldPosition(ArchitectCurve d, Vector3 curvePosition)
Description:
Converts a position on an curve to a world position.
Returns:
The world position.
Vector3 WorldPositionToCurvePosition(ArchitectCurve d, Vector3 worldPosition, int precision, float steps = 5)
Description:
Transforms a world position to its corresponding position on a curve, accounting for both fixed and dynamic time calculations and handling potential curve extensions at both ends.
Returns:
The curve position.