#### Archived

This topic is now archived and is closed to further replies.

# a boat?

This topic is 5324 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

if I have a variable containging for example: y = sin(x) I want an object surfe on top of the wave like a boat. I translate it at the y axis with the sinus formula. but how do I derive the formula so i can change the leaning (k) so that it really looks like it is on the top of the sinus. some example?

##### Share on other sites
you could use the derivative to get the slope of the tangent line.
in this case y''(x) = cos(x)
if you need to get the angle then its a little bit trickier but you could just take arctan(y''(x)) = arctan(cos(x))
there is probably a nice simplification of that expression but its a good start

##### Share on other sites
I didnt want to try simplifying it by hand so I tried to have my Ti89 do it, unfortunatly accroding to it, arctan(cos(x)) is the simplest form.
I tried arctan(1/cos(x)) just for kicks, but the result endedup being more complex. :-/

90*(pi*sign(cos(x))-pi*arctan(cos(x))/90)/pi
(if anyone cares )

##### Share on other sites
yeah, cos(arctan(x)) is a different story, that simplifies rather nicely

arctan(cos(x)) is about (pi/4)cos(x), but its doesnt sound as though you will be calculating more than once per frame so its probably not worth it

##### Share on other sites
I don''t meen to complicate things, but doesn''t this assume the boat is quite a bit smaller than the wavelength of the waves?

If the boat were spanning a wave it''d be more complicated, wouldn''t it? Certainly it would tilt more along it''s shortest dimension...

##### Share on other sites
Yes Thanks for the Answer i wanted this answer to but isnt it possible to just take the Normal of the Triangle its on and us that to calculate angle?

##### Share on other sites
yes, but how do you write derivative in c++?

do I have to include any more h file other than math.h?

##### Share on other sites
dawid - yes of course, I just think the code for the derivative is simpler, cross products get messy. It depends on how the data is being stored.

dennizzz - I don''t even think c++ can do formal derivatives, you would have to precalculate them for a given wave. You could also approximate the limit but if you are going to do that it might be just as simple to use dawid''s cross product suggestion

1. 1
Rutin
47
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 15
• 9
• 10
• 13
• ### Forum Statistics

• Total Topics
633003
• Total Posts
3009842
• ### Who's Online (See full list)

There are no registered users currently online

×