Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Corner Angle Revisited
#1
Bug 
For a while I have been using this code to measure cornering lean

Code:
                //CORNERING LEAN
                float BikeTFDistance = Spline.TFToDistance(BikeTF, CurvyClamping.Clamp);


                Vector3 Cornerbehind = Spline.GetTangentByDistance(BikeTFDistance - 0.5f,Space.World);
                Vector3 Cornercomingup = Spline.GetTangentByDistance(BikeTFDistance + 0.5f, Space.World);
                
                Cornerbehind.y = 0;
                Cornercomingup.y = 0;
                newcornerangle = Vector3.SignedAngle(Cornerbehind, Cornercomingup, Vector3.up);

                delta = newcornerangle - lastcornerangle;

                delta *= Time.deltaTime;

                lastcornerangle += delta;

it was working really well until recently when I realised it was giving me terrible results on splines that aren't totally flat on the xz plane. 

So much so that I drew the tangent lines with this to debug

 
Code:
                float linelength = 5f;
                Debug.DrawLine(mRigidBody.transform.position, mRigidBody.transform.position + Cornerbehind.normalized * linelength, Color.blue, 0.01f);
                Debug.DrawLine(mRigidBody.transform.position, mRigidBody.transform.position + Cornercomingup.normalized * linelength, Color.red, 0.01f);

Added some pictures below - the tangent lines give a really beautiful almost perpendicular tangent against the spline when the spline is flat as you would expect.

   

 As soon as the spline goes even slightly up or down then the tangents shoot off together wildly to the left or right. What could be causing this?
   
Reply


Messages In This Thread
Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-21-2023, 04:54 AM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-21-2023, 12:21 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-22-2023, 05:40 PM
RE: Corner Angle Revisited - by _Aka_ - 12-23-2023, 01:39 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-27-2023, 09:59 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-28-2023, 12:10 PM
RE: Corner Angle Revisited - by _Aka_ - 12-29-2023, 10:26 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 01-01-2024, 04:01 PM
RE: Corner Angle Revisited - by SAMYTHEBIGJUICY - 12-28-2023, 10:59 PM
RE: Corner Angle Revisited - by _Aka_ - 12-29-2023, 08:22 PM
RE: Corner Angle Revisited - by _Aka_ - 01-02-2024, 10:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I find the point on the spline after applying with offset angle+radius? Chanon 1 5 10-01-2022, 11:50 AM
Last Post: _Aka_
  Make hard angle cll3m 5 1,402 07-01-2021, 04:06 PM
Last Post: _Aka_
Wink How to generate right angle road oscar.ken 6 4,687 04-30-2020, 05:38 PM
Last Post: ThomasTheTank
  Twisted mesh at corner on linear path JLeonard 0 2,176 02-24-2017, 04:42 PM
Last Post: JLeonard

Forum Jump: