# SolvedWorldToScreen formula/function

#### sitapea1337

##### Newbie
Full Member
Hey guys

I've been searching quite a while now and I just can't get those maths... I'm not dumb or anything, just those matrixes make me dizzy.

Anyways, I'm aware of that in order to project points from 3D world to 2D (W2S) you need:
PlayerXYZ, MouseX (usually range 0-360 degrees), MouseY (usually range 0-180)
EntityXYZ

Is FOV also needed? My logic says it should be, because how otherwise one would know how "large" your screen is...
Also, FOV should consist of 2 numbers, one X degrees and one Y degrees. You could theoretically have X 360 and Y 90, but then you would need hell of a wide screen or you would get distorted image.
So, FovX and FovY also in formula?

Still, I've looked through all those sources of ESP-s and aimbots and I just can't wrap my head around the logic in matrix and W2S calculation.
Every other part of code is well-documented, except WorldToScreen

Any of you could help me out?

Thanks!

#### sitapea1337

##### Newbie
Full Member
Thanks, man. I'm gonna start off with 2D calculations, because at the moment it's fuzzy for me.

It shouldn't be so hard, I'm just a bit scrambled. I'll read about vectors, angles and so on. Then probably make "line ESP" on XY (3D) and X (2D) only, will leave Z axis out for the moment.

EDIT: Does anyone know if viewX (range 0 to 360) has some standard? Like which way is it 0? When viewing towards X+ axis like in this pictures example? Also, which way does it go?
It seems to be different in different games, which makes developing universal algorithm/function a bit hard.

Check this out, is it correct?

#### Rake

Yup every game can be differrent

#### sitapea1337

##### Newbie
Full Member
Aight, understood.

In your experience, what is the most common? Yaw and pitch, I mean.
Yaw 0 to 360, 0 when looking towards X+ coordinate, counter-clockwise increasing? Or clockwise?
Pitch 0 to 180, 0 when looking at feet, 180 when looking towards sky?

In such case I can make correction function, which turns all game values to "correct" ones, and basically use universal world-to-screen function.

PS: W2S is quite easy though. It gets harder when "roll" comes to play, but with yaw and pitch it's easy, if you understand how 2D, 3D worlds correlate and viewpoint works.

Last edited:

#### Rake

Some games do -90 to +90 for pitch. Most gomes I think use 0->360 ascending in the clockwise direction for yaw. I haven't really hacked alot of games so your experience may be different

#### sitapea1337

##### Newbie
Full Member
All right - thanks for all the help.

I stay away from matrixes (hate those) and will use X,Y,Z coords difference and ATan (Tan-1).
AxisX works great, will implement height/Z soon

EDIT: Works great. Made completely based on player XYZ, yaw, pitch, entity XYZ.
Hate matrix

Check right side, two floats, aiming at entity head is 0,0

Also, crouch correction is easy. When local player is crouching, I subtract some value from player Z and when entity is crouching I subtract some value from entity Z, everything else will be calculated automatically.

https://i.imgur.com/GxrzBB1.jpg

Last edited:
Attention! Before you post:

99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

• Fill out the form correctly
• Tell us the game name & coding language