Post: The Most Useful Math Formula For Mods/Games
10-08-2015, 03:30 AM #1
gopro_2027
Vault dweller
(adsbygoogle = window.adsbygoogle || []).push({}); So I am going to show you guys how to derive a formula that took me about 2 months awhile back to completely derive myself. By the end of this you will be all like "wtf 2 months?" but you gotta give it to me that there were a lot of other factors that went into how this works in different cases depending on what you are doing.

What does this formula do?
Gets the point x units in direction rotx,roty in 3D.

Uses:
GTA V mod menu uses - noclip, aimbot, seeing if a player is visible to you..... ect.
COD uses - aimbot.
Video Game Development Uses - Walking, noclip, making guns, making hands/placing stuff, anything involving getting where you are looking to....

So basically I find this very useful.

The basic equation is this:
x = d*cos(xrot)*cos(yrot)
y = d*sin(yrot)
z = d*sin(xrot)*cos(yrot)

xrot is the players x view rotation and yrot is the players y view rotation.
x,y, and z are the offsets from 0,0,0 so if you did 1 as the distance (d) with a straight up angle it would return (0,1,0) and you just add that to some other coordinates.

Factors that affect the equation:
If the trig in your language is degrees or radians
The exact rotation is usually not perfectly correct so you may have to for example invert the yrot or subtract 90 degrees from the xrot ect...

Here is how it is derived. I will try my best to explain this.
SOH CAH TOA
If you know trig it will greatly help you to understand it.
Picture if this helps you understand why it uses right triangle trig:
You must login or register to view this content.

Extra note:
If you want to port this to a gta menu it would probably help if you understood how it works cuz gta has a weird coordinate system where the y and z are flip flopped.

I hope I helped somebody!

The following 4 users say thank you to gopro_2027 for this useful post:

Boliberrys, ByteSource, Norway-_-1999, Trefad

The following user groaned gopro_2027 for this awful post:

John
10-08-2015, 03:35 AM #2
ByteSource
League Champion
Originally posted by pro View Post
So I am going to show you guys how to derive a formula that took me about 2 months awhile back to completely derive myself. By the end of this you will be all like "wtf 2 months?" but you gotta give it to me that there were a lot of other factors that went into how this works in different cases depending on what you are doing.

What does this formula do?
Gets the point x units in direction rotx,roty in 3D.

Uses:
GTA V mod menu uses - noclip, aimbot, seeing if a player is visible to you..... ect.
COD uses - aimbot.
Video Game Development Uses - Walking, noclip, making guns, making hands/placing stuff, anything involving getting where you are looking to....

So basically I find this very useful.

The basic equation is this:
x = d*cos(xrot)*cos(yrot)
y = d*sin(yrot)
z = d*sin(xrot)*cos(yrot)

xrot is the players x view rotation and yrot is the players y view rotation.
x,y, and z are the offsets from 0,0,0 so if you did 1 as the distance (d) with a straight up angle it would return (0,1,0) and you just add that to some other coordinates.

Factors that affect the equation:
If the trig in your language is degrees or radians
The exact rotation is usually not perfectly correct so you may have to for example invert the yrot or subtract 90 degrees from the xrot ect...

Here is how it is derived. I will try my best to explain this.
SOH CAH TOA
If you know trig it will greatly help you to understand it.
Picture if this helps you understand why it uses right triangle trig:
You must login or register to view this content.

Extra note:
If you want to port this to a gta menu it would probably help if you understood how it works cuz gta has a weird coordinate system where the y and z are flip flopped.

I hope I helped somebody!


best img ever m8
10-08-2015, 03:35 AM #3
gopro_2027
Vault dweller
Originally posted by ByteSource View Post
best img ever m8


lol ikr. I'm not very good with making fancy thready but I just thought I would share this.
10-08-2015, 03:58 AM #4
Trefad
I defeated!
Thanks! Smile
10-08-2015, 01:10 PM #5
vRice
Haxor!
"SOH CAH TOA"

Some old hippie caught another hippie tripping on acid!

That's how my maths teacher taught me to remember that back in high school haha, also thanks for this, I'll look into it more when I feel like scripting again :p
10-08-2015, 09:39 PM #6
gopro_2027
Vault dweller
Originally posted by Trefad View Post
Thanks! Smile


You are welcome!

The following user thanked gopro_2027 for this useful post:

Trefad

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo