# how to set angle between points of a bezier curve

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?

// 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;

• This works perfectly. I created a slider for changing the angle (which is positive or negative) from the inspector editor. When I manually move the control points around (using the mouse in the scene view) I use Vector2.Angle to update the slider angle value. But Vector2.Angle always gives positive angles. How can I get the angle values of Vector2.Angle to coincide (positive and negative) with that of the code above? Commented Oct 3, 2018 at 18:26
• You might want to use Mathf.Atan2 instead. Commented Oct 3, 2018 at 18:28
• I used Mathf.Atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Mathf.PI; but it's also only giving me positive values Commented Oct 3, 2018 at 18:56
• Make sure you're measuring the angle you mean to. You want the difference in the angle between vector AD and vector AB. So Mathf.DeltaAngle(Mathf.Rad2Deg * Mathf.Atan2(p2.y - p1.y, p2.x - p1.x), Mathf.Rad2Deg * Mathf.Atan2(p4.y-p1.y, p4.x-p1.x)) Possibly negated? Or you can use your Vector2.Angle approach and recover the sign by checking whether B is to the right or to the left of D relative to A. Commented Oct 3, 2018 at 21:02
• This might seem simple but it's beating me. Say from the above diagram I want to move D using your solution with the direction still var zeroAngleDirection = (D - A).normalized;. How should I make a "copy" or get the original value of D? I made a slider that I use to change the angle in the editor class so the value of D is always being updated. Commented Oct 24, 2018 at 17:53