Increasing or decreasing theta based on direction of vector

180 Views Asked by At

I am a programmer, and I have some holes in my math knowledge that I am working on filling in. Right now I'm working with a simple process involving drawing curves and straight lines. The line that is drawn has direction and magnitude, and at a random time, there is a circle drawn perpendicular to the straight line, and the line begins to arc around this. I have the arc working. I find theta using atan2, and then I increase or decrease it at a steady rate. Then after a random period of time, the arc stops, and the line continues off along the tangent line.

Increasing or decreasing theta is my issue right now. Instead of smoothly drawing along the circle, it will abruptly begin drawing the arc with theta increasing. I just don't know how to figure out the rule behind increasing or decreasing theta based on the vector. I have a feeling that this will also help me understand how to make it smoothly "leave" the curve, instead of jerk backwards and draw the wrong direction along the tangent line. Below is a simple illustration of how I want it to draw. This is with theta decreasing, with theta set to increase, the red would draw below the dotted line.

enter image description here

Working on building my math vocabulary, but it's not quite there, working on it. I appreciate any help!