// Use this for initialization void Start() { arcLength = 0; measuredArc = 0; transform.position = TelescopeUtils.TranslateAlongHelix(curvature, torsion, arcLength); transform.rotation = TelescopeUtils.RotateAlongHelix(curvature, torsion, arcLength); }
CylinderMesh GenerateInnerCylinder(TelescopeParameters nextParams, bool overhang, float arcOffset, int extraRings = 0) { TelescopeParameters ourParams = getParameters(); CylinderMesh innerCyl; // If there is a change in profile from this shell to the next... if (nextParams != null && (nextParams.curvature != curvature || nextParams.torsion != torsion || nextParams.radius < radius - Constants.WALL_THICKNESS * 1.01f)) { // Generate the outer profile of the child shell; this will become // the inner profile of this shell. TelescopeParameters innerParams = new TelescopeParameters(nextParams.length, nextParams.radius, nextParams.thickness, nextParams.curvature, nextParams.torsion, nextParams.twistFromParent); innerCyl = GenerateCylinder(innerParams, Constants.TAPER_SLOPE, innerGroove: true, overhang: overhang, extraRings: extraRings); // Move and rotate the inner profile so that the end circles align. Quaternion alignRotation = TelescopeUtils.childBaseRotation(ourParams, nextParams); Vector3 alignTranslation = TelescopeUtils.childBasePosition(ourParams, nextParams); Quaternion backRotation = TelescopeUtils.RotateAlongHelix(nextParams.curvature, nextParams.torsion, arcOffset); Vector3 backTranslation = TelescopeUtils.TranslateAlongHelix(nextParams.curvature, nextParams.torsion, arcOffset); innerCyl.ApplyRotation(backRotation); innerCyl.ApplyTranslation(backTranslation); innerCyl.ApplyRotation(alignRotation); innerCyl.ApplyTranslation(alignTranslation); } else { TelescopeParameters innerParams = new TelescopeParameters(length, radius - thickness, thickness, curvature, torsion, 0); innerCyl = GenerateCylinder(innerParams, Constants.TAPER_SLOPE, innerGroove: (nextParams != null), overhang: overhang, extraRings: extraRings); if (nextParams != null) { Quaternion backRotation = TelescopeUtils.RotateAlongHelix(nextParams.curvature, nextParams.torsion, arcOffset); Vector3 backTranslation = TelescopeUtils.TranslateAlongHelix(nextParams.curvature, nextParams.torsion, arcOffset); innerCyl.ApplyRotation(backRotation); innerCyl.ApplyTranslation(backTranslation); } } return(innerCyl); }
OrthonormalFrame TransformedHelixFrame(CurveSegment cs, float arcLen) { // Apply the local helix rotation. Quaternion oldRot = Quaternion.LookRotation(cs.frame.T, cs.frame.N); Quaternion newRot = oldRot * TelescopeUtils.RotateAlongHelix(cs.curvature, cs.torsion, arcLen) * Quaternion.Inverse(oldRot); OrthonormalFrame newFrame = cs.frame.RotatedBy(newRot); return(newFrame); }
// Update is called once per frame void Update() { arcLength += Time.deltaTime; Vector3 pos = TelescopeUtils.TranslateAlongHelix(curvature, torsion, arcLength); float diff = Vector3.Distance(pos, transform.position); measuredArc += diff; transform.position = pos; transform.rotation = TelescopeUtils.RotateAlongHelix(curvature, torsion, arcLength); velocity = diff / Time.deltaTime; }
public Quaternion rotationOfDistance(float arcLength, float curvature, float torsion) { return(TelescopeUtils.RotateAlongHelix(curvature, torsion, arcLength)); }