PeterCanessa Oh
Registered User
Join date: 15 Jul 2008
Posts: 10
|
12-02-2009 19:01
I'm being a bit cheeky here since I don't have a problem with the LSL, just the maths I'm meant to be using in the first place. Indulge me  I've become addicted to SL sailing and am trying to write a HUD that will tell me where I should tack. For this I need to find the point that is , say, 40 degrees FROM my current position AND 40 degrees TO (or, the reciprocal, 220 FROM) the mark I'm trying to reach. There will be two answers (port and starboard tack), which is not a problem since I can then use llVecDist() to pick the nearest. Starting with llGetPos() and a Mark vector (only x and y are relevant), how do I calculate these waypoints?
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-02-2009 19:28
2d trig
you current position forms the base of a triangle, your tack angles decide the length of the legs.... the formula you'll have to look up yourself
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
|
12-03-2009 07:30
Don't forget to learn all about RADIANS (used instead of DEGREES).
Also, sometimes, sailboats ignore Linden Wind and use Sailboat racing wind.
lee
_____________________
So many monkeys, so little Shakespeare.
|
PeterCanessa Oh
Registered User
Join date: 15 Jul 2008
Posts: 10
|
12-03-2009 16:24
Thank you both. My maths is worse than I thought. I'm using race-wind which actually makes it easier and converting deg-rad-deg is not a problem for the operations. I've been playing around with how the thing looks instead of what it actually does so I'd better knuckle down to reading the trigonometry sites.
I'll post back here with the functions I finally come up with.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-03-2009 16:48
the function you want will be 1 side and two angle. the maths will work exactly the same in LSL as radians, so you never need to convert them.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|