br_scalar
br_scalar
332
type is the general numerical representation used by BRender. Under the fixed point library, br_scalar
332
is a 32 bit fixed point number (sign + 15 bit integer + 16 bit fraction), and can represent numbers between approximately -32768 and +32768. Under the floating point library, br_scalar
332
is a float
, and can represent numbers between approximately -3.4e38 and +3.4e38.
Use br_scalar
332 instead of int, float or double, in all numerical modelling aspects of an application program.
typedef
scalar.h
for precise declaration)
float br_scalar Floating point
br_fixed_ls br_scalar Fixed - Long Signed (15.16)
Arithmetic
No standard arithmetic operators are supported. The following macros should be used instead. All arguments and return values are of type br_scalar
332 (except where otherwise stated).
BR_ADD(a,b)
Return the equivalent of a + b
.
BR_SUB(a,b)
Return the equivalent of a - b
.
BR_CONST_MUL(a,x)
Return the equivalent of a * x
(where x
is a numeric constant).
BR_MUL(a,b)
Return the equivalent of a * b
.
BR_SQR(a)
Return the equivalent of a * a
.
BR_RCP(a)
Return the equivalent of 1.0 / a
.
BR_CONST_DIV(a,x)
Return the equivalent of a / x
(where x
is a numeric constant).
BR_DIV(a,b)
Return the equivalent of a / b
.
BR_DIVR(a,b)
Return the equivalent of a / b
(rounding toward zero instead of negative infinity*1).
BR_MULDIV(a,b,c)
Return the equivalent of a * b / c
.
BR_ABS(a)
Return the equivalent of fabs( a )
.
BR_POW(a,b)
Return the equivalent of pow( a , b )
.
BR_SQRT(a)
Return the equivalent of sqrt( a )
.
BR_SQR2(a,b)
Return the equivalent of a * a + b * b
.
BR_LENGTH2(a,b)
Return the equivalent of sqrt( a * a + b * b )
.
BR_RLENGTH2(a,b)
Return the equivalent of ( 1.0 / sqrt( a * a + b * b ))
.
BR_MAC2(a,b,c,d)
Return the equivalent of a * b + c * d
.
BR_MAC2DIV(a,b,c,d,e)
Return the equivalent of ( a * b + c * d ) / e
.
BR_SQR3(a,b,c)
Return the equivalent of a * a + b * b + c * c
.
BR_LENGTH3(a,b,c)
Return the equivalent of sqrt( a * a + b * b + c * c )
.
BR_RLENGTH3(a,b,c)
Return the equivalent of ( 1.0 / sqrt( a * a + b * b + c * c ))
.
BR_MAC3(a,b,c,d,e,f)
Return the equivalent of a * b + c * d + e * f
.
BR_MAC3DIV(a,b,c,d,e,f,g)
Return the equivalent of ( a * b + c * d + e * f ) / g
.
BR_SQR4(a,b,c,d)
Return the equivalent of a * a + b * b + c * c + d * d
.
BR_LENGTH4(a,b,c,d)
Return the equivalent of sqrt( a * a + b * b + c * c + d * d )
.
BR_RLENGTH4(a,b,c,d)
Return the equivalent of ( 1.0 / sqrt( a * a + b * b + c * c + d * d ))
.
BR_MAC4(a,b,c,d,e,f,g,h)
Return the equivalent of a * b + c * d + e * f + g * h
.
BR_MAC4DIV(a,b,c,d,e,f,g,h,i)
Return the equivalent of ( a * b + c * d + e * f + g * h ) / i
.
Comparison
Equality and comparison with zero are valid. Other standard comparison operators may be implemented by macros in future versions, but are currently valid. Conversion
From Numeric Constants
Convert BR_SCALAR(x)
x
from any numeric constant to scalar type. Also see BR_CONST_MUL()
and BR_CONST_DIV()
.
Smallest representable positive scalar value.BR_SCALAR_EPSILON
Largest representable negative scalar value.BR_SCALAR_MIN
Largest representable positive scalar value.BR_SCALAR_MAX
From Integral Types
br_scalar
Converts BrIntToScalar
(int i)
i
from any integer type to scalar type.
br_scalar
Converts BrFloatToScalar
(int i)
i
from float
or double
type to scalar type. From Other BRender Types
br_scalar
Converts BrAngleToScalar
(br_angle a)
a
from angle type to scalar type.
br_scalar
Converts BrFixedToScalar
(br_fixed_ls f)
f
from fixed type to scalar type.
br_scalar
Converts BrFractionToScalar
(br_fraction f)
f
from fraction type to scalar type.
br_scalar
Converts BrUFractionToScalar
(br_ufraction u)
u
from unsigned fraction type to scalar type. To Integral Types
int
Converts BrScalarToInt
(br_scalar s)
s
from scalar type to int
.
float
Converts BrScalarToFloat
(br_scalar s)
s
from scalar type to float
. To Other BRender Types
br_angle
Converts BrScalarToAngle
(br_scalar s)
a
from scalar type to angle type.
br_fixed_ls
Converts BrScalarToFixed
(br_scalar s)
s
from scalar type to fixed type.
br_fraction
Converts BrScalarToFraction
(br_scalar s)
f
from scalar type to fraction type.
br_ufraction
Converts BrScalarToUFraction
(br_scalar s)
u
from scalar type to unsigned fraction type. Copy/Assign
Only assign zero, or scalars. Use conversions in all other cases.
Generated with CERN WebMaker