namespace: CurveArchitect.Utilites
files: BezierCurve.cs, BezierCurve_Point.cs, BezierCurve_Rotation.cs, BezierCurve_Conversion.cs
General
Vector3 GetPosition(List<Segment> segments, float time, Space space = Space.World)
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<Segment> segments, 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(NativeList<Vector3> positionMap, List<Segment> segments, float positionResolution, float time, Space fallBackSpace = Space.World)
Description:
Quickly retrieves an interpolated position from a pre-mapped list based on time (0 - 1). If the positionMap does not exist, GetPosition will be used.
Returns:
The interpolated position.
Vector3[] GetNormals(ArchitectCurve ac, float timeValue, Space space = Space.World, bool skiprotation = false
Vector3[] GetNormals(ArchitectCurve ac, float timeValue, Quaternion quaternion, Space space = Space.World, 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<Segment> segments, float time, bool backwards = false, Space space = Space.World)
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<Segment> segments, 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<Segment> segments, int segement, float time, Space space = Space.World)
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 segment, 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 GetDirection(List<Segment> segments, float time, bool backwards = false, Space space = Space.World)
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.
Rotation
Quaternion GetZRotation(Vector3 curveDirection, float fixedTime, List<Segment> segments)
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<Segment> segments, 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 ac, 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 ac, 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.
float ClosestTimeStepByStep(List<Segment> segment, NativeList<Vector3> positionMap, float resolution, NativeList<float> lengthMap, float lengthMapStep, Vector3 point, float stepSize, bool ignoreYAxel = false)
Description:
Returns:
The closest time on the Architect Curve.
float ClosestTime(List<Segment> sgments, NativeList<Vector3> positionMap, float resolution, NativeList<float> lengthMap, float lengthMapStep, float curveLength, Vector3 point, int precision, float steps = 5, bool ignoreYAxel = false)
Description:
Returns:
The closest time on the Architect Curve.
Conversion
float ToggleTimeFixedTime(NativeList<float> lengthMap, float lengthMapResolution, 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 ac, Transform parentTransform, Vector3 curvePosition, float4x4 matrix)
Vector3 CurvePositionToWorldPosition(ArchitectCurve ac, Vector3 curvePosition)
Description:
Converts a position on an curve to a world position.
Returns:
The world position.
Vector3 WorldPositionToCurvePosition(ArchitectCurve ac, Transform objectsTransform, 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.
Quaternion CurveRotationToWorldRotation(ArchitectCurve ac, Quaternion rotation, float time)
Description:
Returns:
Quaternion WorldRotationToCurveRotation(ArchitectCurve ac, ArchitectCurveObject aco, float time)
Description:
Converts world rotation to curve roation.
Returns:
A new Quaternion thats converted from world rotation to curve rotation.