Sunday, May 6, 2018

unity - how to set angle between points of a bezier curve


enter image description here


From the bezier curve image above, how can I set the angle r manually, so that changing it does not affect the distance between A and B?



Answer




// Form the direction the tangent should point when the angle is zero.
var zeroAngleDirection = (D - A).normalized;

// Compute a rotation by the desired angle, clockwise about the positive z axis.
var twist = Quaternion.Euler(0, 0, -angle);

// Set point B a desired distance away from A, in the rotated direction.
B = A + twist * zeroAngleDirection * desiredLength;

No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...