Hi, I have an unusual ship 'game' in which I am supposed to code for some of the ship's movements against a sine wave.

Given only the ship speed, wave period and amplitude (no wave length!), in a scenario where the ship and wave are travelling in the same direction, does the assumption that the ship will be constantly on the same point of the wave hold any water? Or is there a way to calculate which point on the wave the ship is on, given only the above mentioned information?

Also, given the same information, I am currently using cos to calculate the position on the wave the ship is on, when the ship and wave are moving in different directions. I take the ship's own movement as the hypotenuse and try to find the adjacent, which is the amount moved across the wave.

in a scenario where the ship and wave are travelling in the same direction, does the assumption that the ship will be constantly on the same point of the wave hold any water?

Pun intended? :)

If they're traveling at the same speed, yes; otherwise, no.

Given only the ship speed, wave period and amplitude (no wave length!)

The period is the wavelength.

I don't see anything that tells us how fast the wave itself is traveling, unless it's meant to be still and you're just tracing the sine wave with your ship.

From the information you've given, it looks like you're supposed to come up with a parameterized function that, given the wave characteristics and a time, returns the ship's position--perhaps something similar to evaluating y = a sin(vt)? (I left out the wave period and motion for now)

Nice catch :)

I meant that I was able to access the wave period in seconds, but not the wave length in metres. Actually I'm supposed to generate the ship's pitch, roll, height and position, based on the given information.

Hi guys,

According to Frédéric Elie, in Ondes de surfaces des liquides, the wave speed, in infinitely deep water is

c = sqrt ( g * lambda / (2 * PI))
where
c is the speed of the phase
g = gravity acceleration = 9.8 m / s²

If you can read french http://fred.elie.free.fr/ondes_surface_liquide.pdf

Regards.
Patrick.

I meant that I was able to access the wave period in seconds, but not the wave length in metres.

Ah. Makes more sense now. Hm. If the ship were motionless, you wouldn't need the physical length of the wave, just the time and amplitude. But if it's moving, I think you'd need the wave length to compare with... offhand, I'm not sure how to do without it, unless you're supposed to have some sort of way to figure the length from the timing--larger waves do roll more slowly than little ones, if I recall correctly.

Actually I'm supposed to generate the ship's pitch, roll, height and position, based on the given information.

I don't know if you have a specific model for the wave and ship, but you should be able to derive them something roughly like this:

  • Lateral position (i.e., not height) is determined by time and ship speed
  • Height is determined by lateral position, wave period/length/amplitude, and time
  • Pitch should be basically the same as the first derivative of the wave at the ship's position
  • There should be no roll if the ship is travelling in the same direction as the wave

Thanks for the replies.

I haven't got to the pitch, roll of the ship as yet, considering that the wave moving at the exact same speed as the ship regardless of the ship's input speed, is weird on paper by itself.

I found something similar to caKus' answer in http://chl.erdc.usace.army.mil/library/publications/chetn/pdf/cancelled/cetn-i-17-C.pdf. Looking around to see if the formulas in there are valid.

An assumption on depth wouldn't affect the rest of the game much, if any, so that may be a valid route to go. Especially in consideration that there appears to be no way to perform the calculations realistically without the wavelength in metres.

I'd start by making sure you're clear on the hydraulic model you're supposed to be using. If it really is just a sine wave, things get much simpler--but it sounds like you may be expected to do more of a simulation.

At the moment, I am pretty sure the wave is only restricted to a sine model. Naturally, I can't say it will stay the same in the future, but as of the moment I will work with that as the target.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.