★ Trigonometric function



ListReference

function

slSin


Sine value calculation

Form

    #include "sgl.h"

    ANGLE ang;
    FIXED slSin (ang)

argument

    ANGLE ang --Angle.

Number of returns

    FIXED-The sine value for a given angle.

function

    Returns a sign for the specified angle. As a value 
    It will be a value from 0xffff0000 to 0x00010000.

caution


    Since the angle data is converted from 0x0000 to 0xfff0 by discarding the lower 4 bits,
    The accuracy is slightly reduced (those using angles below are subject to similar restrictions).

reference

 slCos
 slTan
 slAtan
 slSquart
 slSquartFX
 slMulFX
 slDivFX 



ListReference

function

slCos


Cosine value calculation

Form

    #include "sgl.h"

    ANGLE ang;    
    FIXED slCos (ang)

argument

    ANGLE ang --Angle.

Number of returns

    FIXED- Cosine value for a given angle.

function

    Returns the cosine for the specified angle. As a value 
    It is a value from 0xffff0000 to 0x00010000.

reference

 slSin
 slTan
 slAtan
 slSquart
 slSquartFX
 slMulFX
 slDivFX 



ListReference

function

slTan


Calculation of tangent value

Form

    #include "sgl.h"

    ANGLE ang;
    FIXED slTan (ang)

argument

    ANGLE ang --Angle.

Number of returns

    FIXED-The tangent value for a given angle.

function

    Returns the tangent for the specified angle.

caution


    The tangent value is too large around 90 degrees, so accuracy cannot be expected.

reference

 slSin
 slCos
 slAtan
 slSquart
 slSquartFX
 slMulFX
 slDivFX 



ListReference

function

slAtan


Inverse tangent calculation

Form

    #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

Number of returns

    FIXED- Inverse tangent value for a 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

Form

    #include "sgl.h"

    Uint32 val;
    Uint16 slSquart (val)

argument

    Uint32 val-value.

Number of returns

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

function

    Calculates the square root of an unsigned integer.

reference

 slSin
 slCos
 slTan
 slAtan
 slSquartFX
 slMulFX
 slDivFX 



ListReference

function

slSquartFX


Square root operation

Form

    #include "sgl.h"

    FIXED val;
    FIXED slSquartFX (val)

argument

    FIXED val-value.

Number of returns

    FIXED The square root value of the given value.

function

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

caution


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

reference

 slSin
 slCos
 slTan
 slAtan
 slSquart
 slMulFX
 slDivFX 


★ Multiplication and division



ListReference

function

slMulFX


Multiplication of fixed decimals

Form

    #include "sgl.h"

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

argument

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

Number of returns

    FIXED-The result of multiplying the argument by the number given.

function

    Multiplies fixed decimals and returns the result.

reference

 slSin
 slCos
 slTan
 slAtan
 slSquart
 slSquartFX
 slDivFX 



ListReference

function

slDivFX


Fixed decimal division

Form

    #include "sgl.h"

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

argument

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

Number of returns

    FIXED-The result of dividing the number given to the argument.

function

    Divides between fixed decimals and returns the result (b / a).

reference

 slSin
 slCos
 slTan
 slAtan
 slSquart
 slSquartFX
 slMulFX 


★ Vector calculation



ListReference

function

slInnerProduct


Dot product calculation

Form

    #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.

Number of returns

    FIXED-Inner product calculation result.

function

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

Example

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

reference

 slNormalVector 



ListReference

function

slNormalVector


Find the normal vector of the plane containing 3 points

Form

    #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 --Three points that make up the plane.
VECTOR ans- VECTOR structure for storing operation results.

Number of returns

    void --Nothing is returned. (However, the normal vector of the calculation result is returned in ans given as an 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, c.

reference

 slInnerProduct 


★ Random numbers



ListReference

function

slRandom


Find a random number

Form

    #include "sgl.h"

    FIXED slRandom (void)

argument

    void --Do not give anything.

Number of returns

    FIXED -Random value.

function

    Generate a random number between 0 and 1.0.

Example

    FIXED x, y;

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

caution


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

reference

 slInitSystem
 RandWork 


★ Motion / collision related



ListReference

function

slBezier


Find the value on the Bezier curve connecting four points

Form

    #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 --Four points that make up a Bezier curve.
VECTOR time --When pnt_a is 0.0 and pnt_d is 1.0, A point with a function value you want to know.
VECTOR ans; --VECTOR structure for storing operation results.

Number of returns

    void --Nothing is returned. (However, the vector of the calculation result is returned in ans given as an argument.)

function

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

reference



ListReference

function

slBallCollision


Judge collision between balls

Form

    #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.

Number of returns

    FIXED- Returns the distance between the two if hit, or a negative number if not hit.

function

    Collision detection is performed between a sphere whose position is object [ XYZ ] and radius is size1 and a sphere whose position is object2 [XYZ ], size2, and if it is hit, the distance is returned.
If it does not hit, it returns a negative value.

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 function to be executed by slave CPU

Form

    #include "sgl.h"

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

    void slSlaveFunc (func, para);

argument

    void (* func) ()-The function you want to execute on the slave.
void * para --Arguments given to the function executed on the slave.

Number of returns

    void --Nothing is returned.

function

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

Example

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

reference


return
Copyright SEGA ENTERPRISES, LTD., 1997