Maths (yay) - Rotating an object around a point other than the center
#1

I'm trying to rotate the bank vault door in the Caligulas Vault around the hinges. Unfortunately the MoveObject() rotation parameters rotate the object around the center, which messes it up, as seen here:

[ame]http://www.youtube.com/watch?v=clwfI9Id4qY[/ame]

I need it to rotate around the hinges..


(And yes, I do have the handwriting of a 5 year old (+ I rushed!) :x)
Curved line drawn accurately with a compass

X = Center of the vault door object
The corner is the HINGES of the door, around which I want to rotate the door
The straight line from the X to the X is the MoveObject() POSITION interpolation, which is the problem
The dashed (well, outlined with dashed lines because I forgot) is the line which the position NEEDS to interpolate around to work

The door will move from rotation 180 -> 270 (90 degrees). I will use a fast timer to move it in 90 steps, one degree at a time. I just need to work out how to calculate the position. It will of course also have to be relative to wherever the door is.

If anything isn't clear, please let me know and I'll try to explain further. It seems fairly simple though.

Information that may be required:

Width (here ------ to here) of vault door: 1.99 in-game units (meters?) I guess it can be rounded to 2..

Here the script used in the video: http://pastebin.com/jJcgPsYL

Thank you :<

EDIT:

I just had an idea - perhaps I can use a mid-point to at least make it a BIT better:

Reply
#2

If I understood correctly your problem solution is when you place object first time you also put another object in position when it's opened. Just make sure hinges are in same position.
Reply
#3

Are you suggesting I instantly set the position of the door and don't interpolate it? That's clearly not a solution - it's a compromise I don't want to make. Attention to detail.
Reply
#4

Looks a little bit weird because the node of that door is in the center if i'm not mistaken you should make this with several frames to get a smoother animation.
Reply
#5

You could make a function to get the co ords of the semi - ish circle made by that line (like the one you have roughly made) and then do something like updating each move object with those new co-ordinates? Would it work?
Reply
#6

^ That's what I'm trying to do - I need to work out how to get the coordinates.

I think this may actually be a lot simpler than I imagined. The curved line is a quarter-circle, so sin/cos needs using, I know that much. The mid-point of the vault door object is 1 meter/unit out, so it's just a unit circle..

I'm thinking it's simply going to be

sin/cos 180
->
sin/cos 270

and that will give me the x/y offset (from the hinges).
Reply
#7

I can't honestly think of something else, but what I came up with needs the angle. It's probably useless because it needs the angle which is hard to calculate. You could do computer integration, like getting the co - ords for each point as angle tends to 0.
The circle (semi) you make with the line, suppose has a radius R, you consider a dθ angle and then, R*dθ = the curve's length. But it'd be so small, tending to a point. But I don't know how we can use this to get the co - ordinates. Unless you consider the hinge as the origin (X - Y axis) and then calcuate the distance from there using the distance formula/slope method/perpendicular distance.
All that blab..
Reply
#8

Quote:
Originally Posted by MP2
Посмотреть сообщение
Are you suggesting I instantly set the position of the door and don't interpolate it? That's clearly not a solution - it's a compromise I don't want to make. Attention to detail.
No. Like that you'll get co-ordinates of open doors like it has opened over hinges.
Reply
#9

I did that. Didn't you watch the video? The issue is the position interpolates around the center of the object, not the hinges.

At the mid-point, the x and y offset should be EXACTLY the same:

Sin 45 = 0.70710678118
Cos 45 = 0.70710678118

They are! I think I'm on to something here.
Reply
#10

Try to move the object abit more out of the entrance so the hinges won't go in the wall? And then set it back to the place it is is supposed to be?


I had also the same problem with the same object,I didn't really care about it thought. I wasn't even using a moveobject function,I was directly rotating the door to an open position and I had realised the hinges were inside the wall so I moved them a bit more further.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)