Pendulum motion

Started by
3 comments, last by d9930380 21 years, 9 months ago
Hi, I''m looking to implement a platform connected via a rope to the ceiling. Which when you jump on to it acts like a "3D Pendulum" that also has swirls etc (doesn''t just move in 1 plane) I have the normal 2D platform working however I don''t have any idea how to convert the 2D equations into 3D. Can anyone provide any help or useful links.
Advertisement
I''d imagine (?) that it''d be possible to do this by resolving/equating forces and mass-accelerations. The forces will be in the string, and gravity, and possibly the momentum from jumping on the rope and/or air resistance. Then if you add all these together, you can probably divide by the mass (or something - haven''t done this for a few years ) of the pendulum to get the acceleration vector. Then treat this as you would normally, and use it to adjust the velocity vector, and hence position. In the new position, the forces will have changed, and it carries on from there.

I think that''s right... Oh, but in its simple form, assumes the rope has no mass. Depends whether or not that''s a problem. Maybe considering the rope as lots of little bits of rope, with small masses at the joins would give an approximation. No doubt there''s a more exact way of doing that though.

Miles
I tried to do what you said and it sort of works except it''s not :-)

Could you have a look at my code that generates my resultant force: ( I then add this resultant to my linear momemtum and then divide by the weight to get the velocity)

Thanks in advance

Code Begin:

// Apply gravity
resultant_force.x = 0.0
resultant_force.y = MASS_WEIGHT * GRAVITY
resultant_force.z = 0.0

// Apply the force caused by the player
resultant_force = resultant_force + player_force

// Get the magnitude of this force
float resultant_force_magnitude
resultant_force_magnitude = vectorlength( resultant_force )

// Normalize this resultant force
vec3 unit_resultant_force
unit_resultant_force.x = resultant_force.x / resultant_force_magnitude
unit_resultant_force.y = resultant_force.y / resultant_force_magnitude
unit_resultant_force.z = resultant_force.z / resultant_force_magnitude

//Apply the force caused by the chain
vec3 chain_vector
chain_vector.x = object_xpos - chain_start_x
chain_vector.y = object_ypos - chain_start_y
chain_vector.z = object_zpos - chain_start_z

// Normalize this chain_vector
chain_vector.x /= chain_length
chain_vector.y /= chain_length
chain_vector.z /= chain_length

float dot_product
dot_product = unit_resultant_force.x * chain_vector.x
dot_product += unit_resultant_force.y * chain_vector.y
dot_product += unit_resultant_force.z * chain_vector.z

float factor
factor = -( dot_product*resultant_force_magnitude )

vec3 chain_force
chain_force.x = chain_vector.x * factor
chain_force.y = chain_vector.y * factor
chain_force.z = chain_vector.z * factor

// Apply the chain force
resultant_force = resultant_force + chain_force
I''ve been trying to work out how to do this, and I haven''t managed it yet . I think I know what you are trying to do with the code (which is the same method I started with), but I think it relies on the assumption that the acceleration vector is perpendicular to the chain vector. This is what would normally happen were there no player force, but I''ve got a feeling that the player force might skew this. But I''m not entirely sure. Have you tried it when the player force is zero? I think your code should work as a normal pendulum.

Miles
Ok, I think I understand it better now. What your code works out should be fine as long as the string/rope remains taught. This can be determined by seeing if dot_product is negative or not. If it is, then everything should be ok. If it isn''t, then you must ignore the string, and consider the object as if it weren''t attached.

I''ve just realised something. Your chain_vector is pointing towards your object, rather than away from it. If you make it the other way around, then it should work ok (I think).

Miles

This topic is closed to new replies.

Advertisement