Japanese

★Trigonometric functions



ListReference

function

slSin


Calculation of sine value

Format

    #include "sgl.h"

    ANGLE ang;
    FIXED slSin( ang )

argument

    ANGLE ang - Angle.

Return number

    FIXED - Sine value for the given angle.

function

Returns the sine of the specified angle. As a value The value will be between 0xffff0000 and 0x00010000.

Note

The angle data discards the lower 4 bits and is converted to 0x0000 to 0xfff0, so Accuracy is slightly lower (those using angles are subject to similar limitations).

reference

 slCos
 slTan
 slAtan
 slSquart
 slSquartFX
 slMulFX
 slDivFX 



ListReference

function

slCos


Cosine value calculation

Format

    #include "sgl.h"

    ANGLE ang;    
    FIXED slCos( ang )

argument

    ANGLE ang - Angle.

Return number

    FIXED - Cosine value for the given angle.

function

Returns the cosine of the specified angle. As a value A value between 0xffff0000 and 0x00010000.

reference

 slSin
 slTan
 slAtan
 slSquart
 slSquartFX
 slMulFX
 slDivFX 



ListReference

function

slTan


Calculation of tangent value

Format

    #include "sgl.h"

    ANGLE ang;
    FIXED slTan( ang )

argument

    ANGLE ang - Angle.

Return number

    FIXED - Tangent value for the given angle.

function

Returns the tangent of the specified angle.

Note

Accuracy cannot be expected because the tangent value is too large near 90 degrees.

reference

 slSin
 slCos
 slAtan
 slSquart
 slSquartFX
 slMulFX
 slDivFX 



ListReference

function

slAtan


Calculating arctangent value

Format

    #include "sgl.h"

    FIXED x_pos, y_pos;
    ANGLE slAtan( x_pos, y_pos )

argument

    FIXED x_pos - X coordinate value
    FIXED y_pos - Y coordinate value

Return number

    FIXED - Arctangent value for the given vector.

function

Returns the angle in the specified direction.

reference

 slSin
 slCos
 slTan
 slSquart
 slSquartFX
 slMulFX
 slDivFX 


★Square root



ListReference

function

slSquart


Square root operation

Format

    #include "sgl.h"

    Uint32 val;
    Uint16 slSquart( val )

argument

    Uint32 val - value.

Return number

    Uint16 The square root value of the given value, rounded down to the nearest whole number.

function

Calculates the square root of an unsigned integer.

reference

 slSin
 slCos
 slTan
 slAtan
 slSquartFX
 slMulFX
 slDivFX 



ListReference

function

slSquartFX


Square root operation

Format

    #include "sgl.h"

    FIXED val;
    FIXED slSquartFX( val )

argument

    FIXED val - value.

Return number

    FIXED Square root value of the given value.

function

Calculates the square root of an unsigned fixed-point number.

Note

Since the calculation is performed as an integer, the precision of the result is an 8-bit integer and an 8-bit decimal.

reference

 slSin
 slCos
 slTan
 slAtan
 slSquart
 slMulFX
 slDivFX 


★Multiply and divide



ListReference

function

slMulFX


Multiplying fixed decimal numbers

Format

    #include "sgl.h"

    FIXED val_a, val_b;
    FIXED slMulFX( val_a, val_b )

argument

    FIXED val_a, val_b - Fixed decimal values used for multiplication.

Return number

    FIXED - The result of multiplying the two numbers given as arguments.

function

Multiplies fixed decimal numbers and returns the result.

reference

 slSin
 slCos
 slTan
 slAtan
 slSquart
 slSquartFX
 slDivFX 



ListReference

function

slDivFX


Fixed decimal division

Format

    #include "sgl.h"

    FIXED val_a, val_b;
    FIXED slDivFX( val_a, val_b )

argument

    FIXED val_a, val_b - Fixed decimal values used for division.

Return number

    FIXED - The result of dividing the two numbers given as arguments.

function

Divides fixed decimal numbers and returns the result (b/a).

reference

 slSin
 slCos
 slTan
 slAtan
 slSquart
 slSquartFX
 slMulFX 


★Vector calculation



ListReference

function

slInnerProduct


Dot product calculation

Format

    #include "sgl.h"

    VECTOR vct_a, vct_b;
    FIXED slInnerProduct( vct_a, vct_b )

argument

    VECTOR vct_a, vct_b - Vector used for dot product operation.

Return number

    FIXED - The result of the dot product operation.

function

Takes the dot product of two vectors and returns the result.

example

    if( slInnerProduct ( normal, eye ) > toFIXED ( 0.0 ) ) {
      slPutPolygonX ( ... );
    }

reference

 slNormal Vector 



ListReference

function

slNormal Vector


Find the normal vector of a plane containing 3 points

Format

    #include "sgl.h"

    VECTOR vct_a, vct_b, vct_c;
    VECTOR ans;

    void slNormalVector( vct_a, vct_b, vct_c, ans )

argument

    VECTOR vct_a, vct_b, vct_c - 3 points that make up the plane.
VECTOR ans - VECTOR structure for storing calculation results.

Return number

    void - returns nothing. (However, the normal vector of the calculation result is returned to the ans argument.)

function

Calculates a vector (unit normal vector) orthogonal to two vectors (b->a, b->c) consisting of the specified three points.
If you want to reverse the direction of the normal, specify the points in the order of b , a , and c.

reference

 slInnerProduct 


★Random number



ListReference

function

slRandom


find random number

Format

    #include "sgl.h"

    FIXED slRandom( void )

argument

    void - gives nothing.

Return number

    FIXED - Random value.

function

Generates a random number between 0 and 1.0.

example

    FIXED x, y;

    x = slMulFX ( slRandom (), toFIXED ( 320 ) );
    y = slMulFX ( slRandom (), toFIXED ( 240 ) );

Note

This function depends on the number of frames from slInitSystem .
In other words, the value of slRandom () immediately after starting slInitSystem will always be the same value. If you call this function immediately after starting slInitSystem , Please note that this has no meaning as a random number.

reference

 slInitSystem
 RandWork 


★Motion/collision related



ListReference

function

slBezier


Find the value of a Bezier curve connecting 4 points

Format

    #include "sgl.h"

    VECTOR pnt_a, pnt_b, pnt_c, pnt_d;
    VECTOR time;
    VECTOR ans; 

    void slBezier( pnt_a, pnt_b, pnt_c, pnt_d, time, ans )

argument

    VECTOR pnt_a, pnt_b, pnt_c, pnt_d - 4 points that make up the Bezier curve.
VECTOR time - When pnt_a is 0.0 and pnt_d is 1.0, A point whose function value you want to know.
VECTOR ans; - VECTOR structure for storing calculation results.

Return number

    void - returns nothing. (However, the vector of calculation results is returned to the ans argument.)

function

Returns the position in time of the Bezier curve connecting the specified four points.
Specify time in the range 0 to 1.0.

reference



ListReference

function

slBallCollision


Determine collision between balls

Format

    #include "sgl.h"

    FIXED obj_a[ XYZ ];
    FIXED size_a;
    FIXED obj_b[ XYZ ];
    FIXED size_b;

    FIXED slBallCollision( obj_a, size_a, obj_b, size_b )

argument

    FIXED obj_a[ XYZ ] - Center coordinates of object A.
FIXED size_a - radius of object A.
FIXED obj_b[ XYZ ] - Center coordinates of object B.
FIXED size_b - radius of object B.

Return number

    FIXED - If it is correct, returns the distance between the two, otherwise returns a negative number.

function

Checks whether the ball with position object [
If not, a negative value is returned.

example

    FIXED Orig[ XYZ ] = { toFIXED ( 0.0 ), toFIXED ( 0.0 ), toFIXED ( 0.0 ) }
    slPushMatrix ();
    {
           :
      slPushMatrix ();
      {
             :
        slConvert3Dto2DFX ( Orig, ans );
        if ( slBallCollision ( ans, radius1, obj, radius2 ) < toFIXED ( 0.0 ) ) {
                 Not Collide
             :
        } else {
                 Collide!!
        }

reference


★Slave



ListReference

function

slSlaveFunc


Registration of functions to be executed by slave CPU

Format

    #include "sgl.h"

    void ( *func )() func;
    void *para;

    void slSlaveFunc( func, para );

argument

    void ( *func )() - the function you want to run on the slave.
void *para - Arguments to give to the function executed on the slave.

Return number

    void - returns nothing.

function

Causes the slave CPU to execute the specified function.
If functions such as polygon display remain in the command buffer to the slave, the function will not be executed until they are finished, so the start of execution may be delayed.

example

    void foo() {
        :
    }
   
    slSlaveFunc ( foo, NULL );

reference


return
Copyright SEGA ENTERPRISES, LTD., 1997