I have the variables "total speed", "x velocity", and "y velocity".
I want to convert the total speed into x velocity and y velocity based on the direction. So if the total speed is 5 and the direction is 45, the x velocity and y velocity would be 2.5. Is there a way of doing this with Trigonometry?
Offline
Indeed there is!
You can try looking at my trig test here for a working example!
In general however, these are the scripts:
X vel = 0 - sin(direction) * speed
Y vel = 0 - cos(direction) * speed
Offline
LS97 wrote:
Indeed there is!
You can try looking at my trig test here for a working example!
In general however, these are the scripts:
X vel = 0 - sin(direction) * speed
Y vel = 0 - cos(direction) * speed
Thanks! That helped a lot. Although I didn't need the "0 -" because It needed to be always be positive but that's not too hard.
Offline
LS97 wrote:
Indeed there is!
You can try looking at my trig test here for a working example!
In general however, these are the scripts:
X vel = 0 - sin(direction) * speed
Y vel = 0 - cos(direction) * speed
I've just come back after a while and tried it again on a different project, there was a bug where the y velocity was either -1.0 or 1.0 when the angle was 0. Why is this? And how do I fix it?
Offline
Splodgey wrote:
LS97 wrote:
Indeed there is!
You can try looking at my trig test here for a working example!
In general however, these are the scripts:
X vel = 0 - sin(direction) * speed
Y vel = 0 - cos(direction) * speedI've just come back after a while and tried it again on a different project, there was a bug where the y velocity was either -1.0 or 1.0 when the angle was 0. Why is this? And how do I fix it?
Oh I just looked at the trig test. It is:
set [x vel v] to ((speed) * ([sin v] of (direction))) set [y vel v] to ((speed) * ([cos v] of (direction)))
Last edited by Splodgey (2012-02-23 09:05:30)
Offline
Splodgey wrote:
Splodgey wrote:
LS97 wrote:
Indeed there is!
You can try looking at my trig test here for a working example!
In general however, these are the scripts:
X vel = 0 - sin(direction) * speed
Y vel = 0 - cos(direction) * speedI've just come back after a while and tried it again on a different project, there was a bug where the y velocity was either -1.0 or 1.0 when the angle was 0. Why is this? And how do I fix it?
Oh I just looked at the trig test. It is:
set [x vel v] to ((speed) * ([sin v] of (direction))) //Not sure why they are variables... set [y vel v] to ((speed) * ([cos v] of (direction)))
I fixed it for you.
Offline
rdococ wrote:
Splodgey wrote:
Splodgey wrote:
I've just come back after a while and tried it again on a different project, there was a bug where the y velocity was either -1.0 or 1.0 when the angle was 0. Why is this? And how do I fix it?Oh I just looked at the trig test. It is:
set [x vel v] to ((speed) * ([sin v] of (direction))) //Not sure why they are variables... set [y vel v] to ((speed) * ([cos v] of (direction)))I fixed it for you.
thanks, I'll edit that. That means there's a bug in Paddle2see's Scratch block generator.
Offline
Splodgey wrote:
rdococ wrote:
Splodgey wrote:
Oh I just looked at the trig test. It is:set [x vel v] to ((speed) * ([sin v] of (direction))) //Not sure why they are variables... set [y vel v] to ((speed) * ([cos v] of (direction)))I fixed it for you.
thanks, I'll edit that. That means there's a bug in Paddle2see's Scratch block generator.
![]()
It's actually by JSO.
Offline
Hardmath123 wrote:
Splodgey wrote:
rdococ wrote:
I fixed it for you.
thanks, I'll edit that. That means there's a bug in Paddle2see's Scratch block generator.
![]()
It's actually by JSO.
![]()
The block generator...?
Better not get off topic...
Last edited by Splodgey (2012-02-23 13:47:27)
Offline
Splodgey wrote:
Hardmath123 wrote:
Splodgey wrote:
thanks, I'll edit that. That means there's a bug in Paddle2see's Scratch block generator.![]()
It's actually by JSO.
![]()
The block generator...?
![]()
Better not get off topic...
yes its by JSO for the forums
[/offtopic]
Offline
fanofcena wrote:
Splodgey wrote:
Hardmath123 wrote:
It's actually by JSO.
![]()
The block generator...?
![]()
Better not get off topic...yes its by JSO for the forums
[/offtopic]
No, no, no not the scratchblocks, the block generator project!
Offline
Splodgey wrote:
fanofcena wrote:
Splodgey wrote:
The block generator...?![]()
Better not get off topic...yes its by JSO for the forums
[/offtopic]No, no, no not the scratchblocks, the block generator project!
oh yes that one is by Paddle2see
[/offtopic permanent]
Offline