#include "sgl.h"
ANGLE ang;
FIXED slSin (ang)
ANGLE ang --Angle.
FIXED-The sine value for a given angle.
Returns a sign for the specified angle. As a value
It will be a value from 0xffff0000 to 0x00010000.
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).
slCos | slTan | slAtan | slSquart |
slSquartFX | slMulFX | slDivFX |
#include "sgl.h"
ANGLE ang;
FIXED slCos (ang)
ANGLE ang --Angle.
FIXED- Cosine value for a given angle.
Returns the cosine for the specified angle. As a value
It is a value from 0xffff0000 to 0x00010000.
slSin | slTan | slAtan | slSquart |
slSquartFX | slMulFX | slDivFX |
#include "sgl.h"
ANGLE ang;
FIXED slTan (ang)
ANGLE ang --Angle.
FIXED-The tangent value for a given angle.
Returns the tangent for the specified angle.
The tangent value is too large around 90 degrees, so accuracy cannot be expected.
slSin | slCos | slAtan | slSquart |
slSquartFX | slMulFX | slDivFX |
#include "sgl.h"
FIXED x_pos, y_pos;
ANGLE slAtan (x_pos, y_pos)
FIXED x_pos --X coordinate value FIXED y_pos --Y coordinate value
FIXED- Inverse tangent value for a given vector.
Returns the angle in the specified direction.
slSin | slCos | slTan | slSquart |
slSquartFX | slMulFX | slDivFX |
#include "sgl.h"
Uint32 val;
Uint16 slSquart (val)
Uint32 val-value.
Uint16 The value rounded down to the nearest whole number of square roots of the given value.
Calculates the square root of an unsigned integer.
slSin | slCos | slTan | slAtan |
slSquartFX | slMulFX | slDivFX |
#include "sgl.h"
FIXED val;
FIXED slSquartFX (val)
FIXED val-value.
FIXED The square root value of the given value.
Calculates the square root of an unsigned fixed-point number.
Since it is operated as an integer, the precision of the result is 8-bit integer and 8-bit decimal.
slSin | slCos | slTan | slAtan |
slSquart | slMulFX | slDivFX |
#include "sgl.h"
FIXED val_a, val_b;
FIXED slMulFX (val_a, val_b)
FIXED val_a, val_b-Fixed decimal value used for multiplication.
FIXED-The result of multiplying the argument by the number given.
Multiplies fixed decimals and returns the result.
slSin | slCos | slTan | slAtan |
slSquart | slSquartFX | slDivFX |
#include "sgl.h"
FIXED val_a, val_b;
FIXED slDivFX (val_a, val_b)
FIXED val_a, val_b --Fixed decimal value used for division.
FIXED-The result of dividing the number given to the argument.
Divides between fixed decimals and returns the result (b / a).
slSin | slCos | slTan | slAtan |
slSquart | slSquartFX | slMulFX |
#include "sgl.h"
VECTOR vct_a, vct_b;
FIXED slInnerProduct (vct_a, vct_b)
VECTOR vct_a, vct_b --Vector used for dot product operation.
FIXED-Inner product calculation result.
Takes the inner product of two vectors and returns the result.
if ( slInnerProduct (normal, eye)> toFIXED (0.0)) {
slPutPolygonX (...);
}
slNormalVector |
#include "sgl.h"
VECTOR vct_a, vct_b, vct_c;
VECTOR ans;
void slNormalVector (vct_a, vct_b, vct_c, ans)
VECTOR vct_a, vct_b, vct_c --Three points that make up the plane.
VECTOR ans- VECTOR structure for storing operation results.
void --Nothing is returned. (However, the normal vector of the calculation result is returned in ans given as an argument.)
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.
slInnerProduct |
#include "sgl.h"
FIXED slRandom (void)
void --Do not give anything.
FIXED -Random value.
Generate a random number between 0 and 1.0.
FIXED x, y;
x = slMulFX ( slRandom (), toFIXED (320));
y = slMulFX ( slRandom (), toFIXED (240));
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.
slInitSystem | RandWork |
#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)
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.
void --Nothing is returned. (However, the vector of the calculation result is returned in ans given as an argument.)
Returns the time position of the Bezier curve connecting the specified four points.
Specify time in the range of 0 to 1.0.
#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)
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.
FIXED- Returns the distance between the two if hit, or a negative number if not hit.
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.
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 !!
}
#include "sgl.h"
void (* func) () func;
void * para;
void slSlaveFunc (func, para);
void (* func) ()-The function you want to execute on the slave.
void * para --Arguments given to the function executed on the slave.
void --Nothing is returned.
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.
void foo () {
::
}
slSlaveFunc (foo, NULL );