In fact, conversion from floating-point numbers to fixed-point numbers is supported in the form of macro definitions, so there is no need for individual conversion by each individual (see "Table 1-1: Macro examples for numeric type conversion"). |
Example) When representing 16.516.5 → 0x0010_8000 | | | | | Decimal part Integer part
Figure 1-4 Angle represented by ANGLE
Figure 1-5 Memory arrangement of matrices
conversion type | macro name | Macro content | how to use |
---|---|---|---|
FIXED | toFIXED(p) | ((FIXED)((p)*65536.0)) | Converting a number to FIXED type |
ANGLE | DEGtoANG(d) | ((ANGLE)((d)*65536.0/360.0)) | Conversion of DEG type angular value to ANGLE type |
FIXED | POStoFIXED(x,y,z) | {toFIXED(x),toFIXED(y),toFIXED(z)} | Converting XYZ coordinates to FIXED type |
Note) Macros are defined in the include files “sgl.h” and “sl_def.h”. |
The sample programs in this book may also use these macros without notice. |
a) Coordinate system used by Sega Saturn (right-handed system) | b) Positive direction of rotation about the Z axis ・When the positive Z direction is placed at the back of the screen, the positive Y direction extends downward and the positive X direction extends toward the right of the screen. ・The positive direction of rotation is to the right of the axis |