TorsionImpulseCurve MakeTorsionImpulseCurve(List <float> impulses, List <float> arcPoints, float constTorsion) { float averageCurvature = AverageCurvature(); Vector3 startingNormal = Vector3.Cross(startingBinormal, startingTangent); OrthonormalFrame startFrame = new OrthonormalFrame(startingTangent, startingNormal, startingBinormal); List <float> arcSteps = new List <float>(); for (int i = 0; i < arcPoints.Count - 1; i++) { arcSteps.Add(arcPoints[i + 1] - arcPoints[i]); } GameObject obj = new GameObject(); obj.name = "TorsionApproxCurve"; TorsionImpulseCurve impulseCurve = obj.AddComponent <TorsionImpulseCurve>(); impulseCurve.InitFromData(impulses, arcSteps, averageCurvature, constTorsion, startFrame, StartingPoint); impulseCurve.SetMaterial(lineRender.material); impulseCurve.BulbShrinkRatio = ActualShrinkRatio; return(impulseCurve); }
TorsionImpulseCurve MakeTorsionImpulseCurve(List <float> impulses, List <float> arcPoints, List <float> curvatureList, List <float> torsionList) { Debug.Log("Arc length of DC = " + ArcLength); Vector3 startingNormal = Vector3.Cross(startingBinormal, startingTangent); OrthonormalFrame startFrame = new OrthonormalFrame(startingTangent, startingNormal, startingBinormal); List <float> arcSteps = new List <float>(); for (int i = 0; i < arcPoints.Count - 1; i++) { arcSteps.Add(arcPoints[i + 1] - arcPoints[i]); } GameObject obj = new GameObject(); obj.name = "TorsionApproxCurve"; TorsionImpulseCurve impulseCurve = obj.AddComponent <TorsionImpulseCurve>(); impulseCurve.InitFromData(impulses, arcSteps, curvatureList, torsionList, startFrame, StartingPoint); impulseCurve.SetMaterial(lineRender.material); return(impulseCurve); }
void AddAxes() { foreach (TelescopeShell shell in segment.shells) { GameObject axisObj = new GameObject(); TorsionImpulseCurve axis = axisObj.AddComponent <TorsionImpulseCurve>(); List <float> impulses = new List <float>(); impulses.Add(0); List <float> arcs = new List <float>(); arcs.Add(shell.length); OrthonormalFrame frame = new OrthonormalFrame(Vector3.forward, Vector3.up, Vector3.left); axis.InitFromData(impulses, arcs, shell.curvature, -shell.torsion, frame, Vector3.zero); LineRenderer axisLR = axis.GetComponent <LineRenderer>(); axisLR.useWorldSpace = false; axisLR.material = lineMaterial; axis.transform.parent = shell.transform; axis.transform.localPosition = Vector3.zero; axis.transform.localRotation = Quaternion.identity; } }