/// <summary> /// Gets the rotation of a point along the line at the specified length /// </summary> /// <param name="normalizedLength"></param> /// <param name="rotationType"></param> /// <returns></returns> public Quaternion GetRotation(float normalizedLength, LineUtils.RotationTypeEnum rotationType = LineUtils.RotationTypeEnum.None) { rotationType = (rotationType != LineUtils.RotationTypeEnum.None) ? rotationType : RotationType; Vector3 rotationVector = Vector3.zero; switch (rotationType) { case LineUtils.RotationTypeEnum.None: default: break; case LineUtils.RotationTypeEnum.Velocity: rotationVector = GetVelocity(normalizedLength); break; case LineUtils.RotationTypeEnum.RelativeToOrigin: Vector3 point = GetPoint(normalizedLength); Vector3 origin = transform.TransformPoint(OriginOffset); rotationVector = (point - origin).normalized; break; } if (rotationVector.magnitude < MinRotationMagnitude) { return(transform.rotation); } Vector3 upVector = GetUpVectorInternal(normalizedLength); if (ManualUpVectorBlend > 0f) { Vector3 manualUpVector = LineUtils.GetVectorCollectionBlend(ManualUpVectors, normalizedLength, Loops); upVector = Vector3.Lerp(upVector, manualUpVector, manualUpVector.magnitude); } if (FlipUpVector) { upVector = -upVector; } return(Quaternion.LookRotation(rotationVector, upVector)); }
protected override Vector3 GetPointInternal(int pointIndex) { float angle = ((float)pointIndex / Resolution) * 2f * Mathf.PI; return(LineUtils.GetEllipsePoint(Radius.x, Radius.y, angle)); }
protected override Vector3 GetPointInternal(float normalizedDistance) { return(LineUtils.GetEllipsePoint(Radius.x, Radius.y, normalizedDistance * 2f * Mathf.PI)); }