Note that there are some explanatory texts on larger screens.

plurals
  1. POCalculating a point in 3D space
    primarykey
    data
    text
    <p>I am trying to locate a point in 3D space relative to the origin (0,0,0). I have 3 values to calculate this point with: a rotation in degrees about both the x and y axis as well as a "view distance". Using these values, how can I locate a point in 3D space relative to the origin? I have tried using basic trigonometric functions, but the results seem to be random. The image below gives a visual as to what needs to be done.</p> <p><img src="https://i.stack.imgur.com/RgjB5.png" alt="enter image description here"></p> <ul> <li>'vd' being the "view distance"</li> <li>'c' being a value holder</li> <li>'(x,y,z)' being the coordinate I am trying to find</li> </ul> <p>What I am trying to do is find the point a player is looking at a certain distance away (find a point in the direct line of sight of the player out a certain distance). Keep in mind, the rotations about the x and y axis are constantly changing, but the view distance remains the same. If anyone has any suggestions, methods of how to do this, or needs clarification, please comment/answer below. </p> <p>I am doing this in LWJGL, and the code I am using is as follows:</p> <pre><code> float c = (float)(Math.cos(Math.toRadians(A00.rot.y)) * view_distance); locate.y = (float)(Math.sin(Math.toRadians(rot.y)) * view_distance); locate.x = (float)(Math.cos(Math.toRadians(rot.x)) * c); locate.z = (float)(Math.sin(Math.toRadians(rot.x)) * c); </code></pre> <p><strong>EDIT:</strong> </p> <p>My issue is that this current setup does NOT work for some reason. The math seems legitimate to me, but I must have something wrong somewhere in the actual setup of the graph..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload