public HandCoords NormalizedCoords(Hand h, float HorizontalAngle, float VerticalAngle) { HandCoords coords = AngleCoords(h); coords.horizontal = (coords.horizontal - (90 - HorizontalAngle / 2)) / HorizontalAngle; coords.vertical = (coords.vertical - (90 - VerticalAngle / 2)) / VerticalAngle; return(coords); }
public HandCoords AngleCoords(Hand h) { Transform hand = h == Hand.Left ? leftHand : rightHand; Transform shoulder = h == Hand.Left ? leftShoulder : rightShoulder; Vector3 directionL = (hand.position - shoulder.position).normalized; float horizontal, vertical; if (directionL.z > 0) { horizontal = Mathf.Acos(-directionL.x) * Mathf.Rad2Deg; } else if (directionL.x > 0) { horizontal = 360 - Mathf.Acos(-directionL.x) * Mathf.Rad2Deg; } else { horizontal = -Mathf.Acos(-directionL.x) * Mathf.Rad2Deg; } if (directionL.z > 0) { vertical = Mathf.Acos(-directionL.y) * Mathf.Rad2Deg; } else if (directionL.y > 0) { vertical = 360 - Mathf.Acos(-directionL.y) * Mathf.Rad2Deg; } else { vertical = -Mathf.Acos(-directionL.y) * Mathf.Rad2Deg; } HandCoords coords = new HandCoords() { horizontal = horizontal, vertical = vertical, length = (hand.position - shoulder.position).magnitude }; return(coords); }
public HandCoords AngleCoords(Hand h) { Transform hand = h == Hand.Left ? leftHand : rightHand; Transform shoulder = h == Hand.Left ? leftShoulder : rightShoulder; Vector3 directionL = (hand.position - shoulder.position).normalized; float horizontal, vertical; if (directionL.z > 0) { horizontal = Mathf.Acos(-directionL.x)*Mathf.Rad2Deg; } else if (directionL.x > 0) { horizontal = 360 - Mathf.Acos(-directionL.x)*Mathf.Rad2Deg; } else { horizontal = - Mathf.Acos(-directionL.x) * Mathf.Rad2Deg; } if (directionL.z > 0) { vertical = Mathf.Acos(-directionL.y) * Mathf.Rad2Deg; } else if (directionL.y > 0) { vertical = 360 - Mathf.Acos(-directionL.y) * Mathf.Rad2Deg; } else { vertical = -Mathf.Acos(-directionL.y) * Mathf.Rad2Deg; } HandCoords coords = new HandCoords() { horizontal = horizontal, vertical = vertical, length = (hand.position - shoulder.position).magnitude }; return coords; }