|
Erwin Goldblatt
Registered User
Join date: 23 Dec 2006
Posts: 41
|
10-14-2007 07:11
Ok I promise this will be easy for anyone with half a brain, but seeing as how I must have an appropriation of about 1/3rd normal size here goes... I wish to calculate the vector position of a point (which is the centre point of a virtual circle path) when I know the length and angle of the intersecting line. Thats a really crappy description isnt it! I did a diagram to help. http://www.exhibitionisland.com/trigmare.gifBasically I need to plot the point to turn around an arc (all that side of things is ok) when approaching the turn point from a non "full degree" angle (ie: 0, 90, 180, 270) - currently 45 degrees (or 225,315 etc). Theres no problem when approaching from the full degrees, but I am stuck on working the calc out when its requiring 2 values... so I looked at cos, sin and tan and had a nervous breakdown.. I think (if I have read it correctly) that I must convert degrees to Radians using the Constant (DEG_TO_RAD) and then do this sort of thing: length = radius_of_circle; angle = vector.x = length * llCos( (DEG_TO_RAD * 45) ); vector.y = length * llSin( (DEG_TO_RAD * 45) ); newpos = vector; //do something with newpos but quite frankly thats scaring me... Erwin
|
|
Malachi Petunia
Gentle Miscreant
Join date: 21 Sep 2003
Posts: 3,414
|
10-14-2007 07:30
The short, poorly described answer is that you should be converting certain points from rectangular to polar coordinates which is what you were doing with your sin/cos transformations. The better answer would be to understand quaternions which makes trig look easy, but probably solves your problem gracefully. http://wiki.secondlife.com/wiki/Rotationhttp://en.wikipedia.org/wiki/QuaternionGood luck.
|
|
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
|
10-14-2007 07:44
Ok, first of all are we assuming that everything is happening parallel to the ground?
If so, it looks like you first need to find a unit vector (ie one with length = 1) that is at right angles to your original vector, then multiply it by 5m, then add the result to your original point.
However, there's one complication. There are 2 points that match that description - you also have one 5m away on the other side of the inbound vector. Do have any way of knowing which you want?
|
|
Erwin Goldblatt
Registered User
Join date: 23 Dec 2006
Posts: 41
|
10-14-2007 08:04
Hi Stephen I posted the above in the middle of some fiddling.... to my suprise the calculation actually worked when I added a smal tweak... I forgot to add the calculated length to the vector! DOH!! vector.x = vector.x + length * llCos( (DEG_TO_RAD * 45) ); vector.y = vector.y + length * llSin( (DEG_TO_RAD * 45) ); I did that - added a known angle and bingo! I flicked around the resources posted by you both as well - and my head is still spinning  Cheers for the help Erwin
|