kinda specific problem
#1

i have a lot of atms (about 160 or more) and for a system im working on i need a extra keypad object attached to them like this:



the atms are obviously in different positions and rotations and my question is how to calculate the position of the keypad on those atms if i only know their position and rotation? I suck at math so if somebody could help ... :/
Reply
#2

well the maths aren't that hard to do.

The offset will be (on any coordinate or rotation) Keypadvaluehere - atmvaluehere.

For example, lets say the atm has the following set of data:
Код:
CreateObject(atmobject, 10.0, 15.0, 20.0, 1.0, 2.0, 3.0);
and the keypad might have this:
Код:
CreateObject(keypadobj, 10.5, 13.0, 35.0, 9.0, 1.0, 5.0);
the you know that the values: keypad - atm = difference/delta/offset (whatever you call it)

10.5-10.0 = 0.5 ---> This means the keypad x-coordinate will always be 0.5 units higher than the atm value.
13.0-15.0 = -2.0 ---> This shows that the keypad will always be 2 units lower in the y-axis every time.
....
and so on.

Create the first keypad on any of the ATM's
Get the offsets
Apply this to all coordinates. (you can do CreateObject(objid, 12.214 + offset, 12414.501 + offset) - if the offset is negative, add the minus instead.)
Voila!
Reply
#3

i figured that i need offsets, but that would only work if the atm always has the same rotation (which it doesn't) ... the offsets completely change when the atm is rotated differently
Reply
#4

I don't see how the offsets change when you rotate it. You gotta rotate the keypad as well.
It could be that rY is relative to the rX on the keypad.

open up a map editor and see in which physical direction it rotates when you change a value. Then compare this to which rotation on the ATM that changes the same physical direction. This way you can find out which values that goes for each.

EDIT:

I realise that the position of the keypad will be relative to the rotation of the ATM.

For instance:


This is possible to solve, if you use trigeometric functions correctly. I don't have time to sit down and set up a equation for it right now (and considering the axes on samp differs from what usually is used). When i get home I'll try to set it up and explain how you could do this.
Furthermore, this documentation may help you: https://math.stackexchange.com/quest...nt-on-a-circle

The keypad moves relatively to a circle when the ATM is rotated. You gotta know the radius. Switch over X and Y and you are getting close.
Reply
#5

I'd suggest to browse all objects and find a better keypad for this, maybe even have a few objects to make the ATM interface as that keypad seems odd for the size of the ATM.

(OCD kicking into overdrive)
Reply
#6

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
I'd suggest to browse all objects and find a better keypad for this, maybe even have a few objects to make the ATM interface as that keypad seems odd for the size of the ATM.

(OCD kicking into overdrive)
yep, this doesn't look too good but that's the easy part, when i get the rotations right i'll change it
Reply
#7

I havent played around with map editing long time, But I guess its something like that:
Object tilted 10 degrees pointed to north is angles: 0, -10 ,0, Pointed to east: -5.5, 5.5, 270, poited to south: -10, 0 ,180...
If so you could even figure out some usable angels and place ATM so you could use these angles.
Reply
#8

Quote:
Originally Posted by VeryTallMidget
Посмотреть сообщение
I havent played around with map editing long time, But I guess its something like that:
Object tilted 10 degrees pointed to north is angles: 0, -10 ,0, Pointed to east: -5.5, 5.5, 270, poited to south: -10, 0 ,180...
If so you could even figure out some usable angels and place ATM so you could use these angles.
Reply
#9

Use AttachObjectToObject or AttachDynamicObjectToObject with correct offsets

You can obtain the offsets if you place your base object at 0.0, 0.0, 0.0 without rotation, then move / rotate your child object to the correct position, the offsets are the child object position and rotation
Reply
#10

I believe this could help you:

http://forum.sa-mp.com/showpost.php?...postcount=2639
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)