SA-MP Forums Archive
Projection on an object - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Projection on an object (/showthread.php?tid=440850)



Projection on an object - ikkentim - 31.05.2013

Hi I am looking for a way to calculate a in-world position from a relative position to an object.

I tried looking at MathPlugin(which is an awesome plugin btw) and it's source, but it didn't help me

Does anyone have ever made some code to do this / knows how to do this?

Thanks!


Re: Projection on an object - Flyfishes - 31.05.2013

I might have misunderstood something but isn't it just to add the relative position to each coordinate of the object?


Re: Projection on an object - ikkentim - 31.05.2013

Quote:
Originally Posted by Flyfishes
Посмотреть сообщение
I might have misunderstood something but isn't it just to add the relative position to each coordinate of the object?
Nope, you are forgetting the rotations

I can do some simple calculations with one-axis rotations, but with this 3D environment I have no clue how to deal with it


Re: Projection on an object - GiamPy. - 31.05.2013

I don't understand what do you want to do.

Quote:

calculate a in-world position from a relative position to an object

What do you mean? In-world you mean real life or in-game? I don't get it.


Re: Projection on an object - ikkentim - 31.05.2013

Example, I have this object

Код:
new obj = CreateObject(2587, 10.0, 10.0, 10.0, 90.0, -90.0, 180.0);
now I want to calculate where the relative position 0.0, 2.0, 1.0 is.
This would be in front of the object, somewhere near 10.0 11.8, 11.3.
That's what I'm trying to calculate

edit:
basically this whilst I got the offset within the space:



Re: Projection on an object - Vince - 31.05.2013

I know what he wants to do, but unfortunately I suck at trigonometry so I have no idea how to do this either. The idea is this:

You have a vehicle/object in the game world at a position, let's say 1500.0, 1200.0, 15.0 with angles 0.0, 0.0, 30.0.
Relative to this vehicle/object is an attached object with offset -0.5, 0.25, 0.15 and rotation 0.0, 0.0, 180.0.
Now he wants to know to position of this second object in relation to the world, rather than in relation to its parent vehicle/object.


Re: Projection on an object - ikkentim - 31.05.2013

I know some functions of the MathPlugin can do it with vehicles, but it uses the vehicle's rotation matrix instead of it's angles..
(I tried figuring out how he did it in his plugin)