Jump to content

Help me with some physical and math questions!


Recommended Posts

Off: One, two, three, four ... days and no post. Wow my topic got old fast! It means that there are a lot of guys scripting in MTA... oh nice thing... (:

---

Hmmm.... Oh... i got understood, you just reduce the calculation... ;D

Hmm, but in with situation this resource will be needed? Cus is much easier to work with the 2D values in a lot of situations ;D

Link to comment

Hmmm, yea a BIT dificult ;P

I think that this is verry used in the 3DS max.

Do you have a idea how a loopgenerator works? I notice that it use a lot of trigonometric stuff.

In the MTA Looop generator i just understood the angle calculation:

  
angle = ((360/pieces)* newpi) -- oh i made something like that in a script file and it made a exactly 360 rotation with 30 objects. Awsome... ;P 
  
>But what about the position?  I know that we use the x,y,z values, use the offset and radius. i know what everything means and how they will work, but noo idea how to make a calculation with positions, mainly ;P 
  

I will try to make a draw and after show you what i got ;D

Link to comment

Oh, i relember now... do you know something about matrix?

It hard to get a idea how it works?

getElementMatrix function?

it allow to calculate offset points bypassing alot of math, but it only works clientside for peds (including player) and vehicles

function getOffsetPoints(element,x,y,z) 
    local matrix = getElementMatrix ( element ) 
    local offX =x * matrix[1][1] + y * matrix[2][1] + z * matrix[3][1] + 1 * matrix[4][1] 
    local offY = x * matrix[1][2] + y * matrix[2][2] + z * matrix[3][2] + 1 * matrix[4][2] 
    local offZ =x * matrix[1][3] + y * matrix[2][3] + z * matrix[3][3] + 1 * matrix[4][3] 
    --Return the transformed point 
    return offX, offY, offZ 
end 

using getOffsetPoints(vehicle,0,10,0) you will get a point located 10m in front of the vehicle no matter the rotation

using getOffsetPoints(vehicle,0,0,5) you will get the point 5 m above

using getOffsetPoints(vehicle,0,0,-5) you will get the point 5 m below

Link to comment

i did not pay attention on math well enough to know that... (this code is 90% wiki exemple)

but ive used it to:

-recalculate speed vector acording to rotation

-calculating the ring marker target, based on dummy element rotation

-calculating the relative teleportation coordinates

in my teleporteditor script, and it works just like i want - its good enough to me ;)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...