DocumentInQuestion.png It has been suggested that this page's contents be merged with the page 3D Projects. You can discuss this on the page's talk page. (April 2023)
Note Warning: This article requires an understanding of trigonometry on a two-dimensional area.

This article shows how to move an object with x, y and z position based on its directions and speeds. A plane as an object to move will be used, but this method applies to almost any object.

Directions

Any three-dimensional object has 3 different directions: its direction respective of the x and y grids, its direction based on its z grid and its direction based on its z grid, and x and y grids.

These are examples showing each of these directions, which will be called dir1, dir2 and dir3 further on in the article, respectively.


Calculating Speeds

All of these directions need to be stored in seperate variables, so the speed of the object can be calculated.

Assuming (vel), the general speed, being 5, and (dir1) being 0, (dir2) being 90 and (dir3) being 0, the specific velocities can be calculated like so:

set [vel-x v] to (([sin v] of (dir1)) * ((vel) * ([sin v] of (dir2))))

set [vel-y v] to (([cos v] of (dir1)) * ((vel) * ([sin v] of (dir2))))

set [vel-z v] to ([cos v] of (dir2))

Sin being used to calculate horizontal speeds and cos for vertical speeds and the direction images above can provide an explanation for this together.

The vel-x formula is extracted from the horizontal speed of dir1, as x is horizontal to the direction in image 1, then in image 2 the x grid appears again, also horizontally, so the velocity has to be multiplied by the sin of dir1 and dir2.

The vel-y formula is extracted from the vertical speed of dir1, as y is vertical to the direction in image 1, it then also appears again in image 2, but horizontally to the direction. So the velocity needs to be multiplied by the cos of dir1 and the sin of dir2.

The vel-z formula is much more simple, as the z grid doesn't appear at all in image 1 and only appears vertically to the direction in image 2. So the velocity only needs to be multiplied by the cos of dir2.

And finally dir3 doesn't modify how an object moves, so there is no need to calculate it.

Extracting the Positions

With the calculated vel-x, the vel-y and vel-z the positions in the grid, which are stored in the three variables (xpos), (ypos) and (zpos) can now be calculated, through the following script:

set [xpos v] to ((xpos) + (vel-x))
set [ypos v] to ((ypos) + (vel-y))
set [zpos v] to ((zpos) + (vel-z))

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.