Japanese
PROGRAMMER'S GUIDEMathematics calculation library
■ | Go forward
Math calculation library

1. guide


1.1 Purpose

The mathematical calculation library is a group of routines that facilitate 3D display, 3D object movement calculations, 32-bit fixed-point calculations, etc.
These routines fall into the following categories:

●Trigonometric functions
Extract the sin and cos values from the table. The table is registered in units of 1 degree, and linear interpolation is performed between 1 degree.

●Matrix calculation processing
Manages matrix stacks and performs matrix composition processing.

●3D coordinate conversion processing by DSP
Hidden surface detection, brightness calculation, and coordinate conversion processing for polygon data used in the sprite 3D display library are all performed by DSP.

●Perspective conversion processing
Performs a perspective transformation from 3D to 2D screen in the viewpoint coordinate system.
The viewpoint position is the origin, and the screen position is -1.0 on the Z axis.

●Random number generation process
Generate random numbers in the range 0 to 0xffffffff for use in the game.

●Spline curve calculation process
This curve calculation function uses cubic spline curves and has the following characteristics:
(1) Supports 2D and 3D coordinates
(2) Tangent vectors at each output coordinate can be obtained
As shown in Figure 1, by specifying just a few points, you can obtain points on a curve that smoothly passes through that point. Figure 1 shows that if you specify the input coordinate array P0~3, the number of arrays 4, and the number of output coordinates 10, you can obtain the output coordinate array c0~9 that smoothly passes through that point. Also, by using the tangent function, you can obtain the tangent vector at each output coordinate. Tangent vectors can be used for things such as the character's direction of movement.

Figure 1 Conceptual diagram of curve calculation

●Fixed-point calculation
There are routines and macros that perform multiplication and division of 32-bit fixed-point data (16-bit integer part + 16-bit fractional part) and mutual type conversion with integer and floating-point data.

●Other functions
Other numerical calculation functions other than those listed above.


■ | Go forward
PROGRAMMER'S GUIDEMathematics calculation library
Copyright SEGA ENTERPRISES, LTD., 1997