I want to calculate the distance d that moves the beta angled blue line out of unit circle center so that both alpha angles are equal.
Seems not so easy than i initially thought - please help
Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 18 March 2013 - 08:15 PM
Posted 19 March 2013 - 02:01 AM
Thx, but that would be only a part of the solution - Initially i have the line at the light blue position and alpha is unknown.
Note that if beta angle becomes larger, there should be more movement in d direction and alpha angle becomes larger too.
If i'd know alpha i could calculate d and vice virsa.
But if beta is 90 deg., any solution for d is correct, but alpha is 90 deg. So asking for alpha would have been wiser than asking for d.
I tried things like sin(alpha) = pow(sin(beta), 2) or sin(alpha) = sqrt(sin(beta))
Both work for 0 and 90 degree case, but not in between.
Posted 20 March 2013 - 09:55 AM
Posted 20 March 2013 - 12:32 PM
So, I ended with a quadratic equation, so there are two solutions, but one of them quite doesn't make sense, but you'll see when you try it (it gives you a negative d so large that the line would be completely out of the circle).
The quadratic equation looks like this:
d^2 * sin(beta) + d * R - R^2 * sin(beta) = 0
where d is your unknown variable, beta is the angle and R is radius of the circle. You said a unit circle so R probably will be 1, but it was better to make it universal I think ;)
The better of the two solutions is:
D = R^2 + 4 * (sin(beta))^2 * R^2 d = (-R + sqrt(D)) / (2 * sin(beta))
Because of one algebraic operation I did in the process, there arose a condition that cos(beta) cannot be zero. Which makes sense, because that's true for beta = 90°.
If you're interested in the whole calculation, let me know and I'll post it somehow.
Edited by Tom KQT, 20 March 2013 - 12:33 PM.
Posted 03 April 2013 - 06:49 AM
I tested it a little bit more and it is working as expected.
May I please ask you - next time let us know on the forum when you aren't looking for the solution anymore. It's quite sad when somebody else is spending a good amount of time solving your problem for you, just to find then that you didn't probably even read the thread.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.