FrontWheelTracker.cs 777 B

1234567891011121314151617181920212223
  1. using System;
  2. using UnityEngine;
  3. namespace Tracking
  4. {
  5. public class FrontWheelTracker : CalibratableTracker
  6. {
  7. protected override string KeyPrefix => "fw";
  8. public float trackerDistanceToWheelCenterPoint;
  9. public KineticLegTracker legTracker;
  10. public float SteerRotation
  11. {
  12. get
  13. {
  14. //legTracker position is added to compensate movements of the whole installation
  15. var posOnBikePlane = Vector3.ProjectOnPlane(RelativePosition + legTracker.RelativePosition, bicycleTransform.up);
  16. var theta = Mathf.Acos(Mathf.Clamp(posOnBikePlane.x / trackerDistanceToWheelCenterPoint, -1f, 1f));
  17. return 90f - theta * Mathf.Rad2Deg;
  18. }
  19. }
  20. }
  21. }