201 lines
4.3 KiB
Plaintext
201 lines
4.3 KiB
Plaintext
|
|
=encoding UTF-8
|
||
|
|
|
||
|
|
|
||
|
|
=head1 NAME
|
||
|
|
|
||
|
|
BH_Vec2f - two-dimensional real vector
|
||
|
|
|
||
|
|
|
||
|
|
=head1 SYNTAX
|
||
|
|
|
||
|
|
#include <BH/Math/Vec2f.h>
|
||
|
|
|
||
|
|
cc prog.c -o prog -lbh
|
||
|
|
|
||
|
|
|
||
|
|
=head1 DESCRIPTION
|
||
|
|
|
||
|
|
The BH_Vec2f module provides a set of functions for working with two-dimensional
|
||
|
|
vectors. It includes operations for addition, subtraction, multiplication,
|
||
|
|
scaling, calculating the dot and cross product, as well as normalizing vectors.
|
||
|
|
|
||
|
|
|
||
|
|
=head1 API CALLS
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fAdd
|
||
|
|
|
||
|
|
void BH_Vec2fAdd(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the sum of two vectors I<a> and I<b>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fSub
|
||
|
|
|
||
|
|
void BH_Vec2fSub(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the difference between two vectors I<a> and I<b>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fMul
|
||
|
|
|
||
|
|
void BH_Vec2fMul(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the result of multiplying two vectors I<a> and I<b>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fScale
|
||
|
|
|
||
|
|
void BH_Vec2fScale(const float a[2],
|
||
|
|
float b,
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the result of multiplying vector I<a> by value I<b>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fMulAdd
|
||
|
|
|
||
|
|
void BH_Vec2fMulAdd(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
const float c[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the result of the sum I<c> and the product of vectors I<a> and I<b>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fNegate
|
||
|
|
|
||
|
|
void BH_Vec2fNegate(const float in[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the opposite vector from vector I<in>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fDot
|
||
|
|
|
||
|
|
float BH_Vec2fDot(const float a[2],
|
||
|
|
const float b[2]);
|
||
|
|
|
||
|
|
Calculates the dot product of vectors I<a> and I<b>.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fCross
|
||
|
|
|
||
|
|
float BH_Vec2fCross(const float a[2],
|
||
|
|
const float b[2]);
|
||
|
|
|
||
|
|
Calculates the cross product of vectors I<a> and I<b>.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fLength
|
||
|
|
|
||
|
|
float BH_Vec2fLength(const float in[2]);
|
||
|
|
|
||
|
|
Calculates the length of vector I<in>.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fNormal
|
||
|
|
|
||
|
|
void BH_Vec2fNormal(const float in[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the normalized form of vector I<in>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fNormalEx
|
||
|
|
|
||
|
|
float BH_Vec2fNormalEx(const float in[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the normalized form of vector I<in> and returns its original length.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fMin
|
||
|
|
|
||
|
|
void BH_Vec2fMin(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the element-wise minimum of two vectors I<a> and I<b>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fMax
|
||
|
|
|
||
|
|
void BH_Vec2fMax(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the element-wise maximum of two vectors I<a> and I<b>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fLerp
|
||
|
|
|
||
|
|
void BH_Vec2fLerp(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
float t,
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Performs linear interpolation between two vectors I<a> and I<b> with parameter
|
||
|
|
I<t>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fProject
|
||
|
|
|
||
|
|
void BH_Vec2fProject(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the result of projecting vector I<a> onto vector I<b>.
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head2 BH_Vec2fBarycentric
|
||
|
|
|
||
|
|
void BH_Vec2fBarycentric(const float a[2],
|
||
|
|
const float b[2],
|
||
|
|
const float c[2],
|
||
|
|
float v,
|
||
|
|
float w,
|
||
|
|
float out[2]);
|
||
|
|
|
||
|
|
Calculates the vector from the barycentric coordinates I<v>, I<w> and vectors of
|
||
|
|
points I<a>, I<b>, I<c>.
|
||
|
|
|
||
|
|
The calculation is performed using the formula A + v*(B-A) + w*(C-A).
|
||
|
|
|
||
|
|
The I<out> parameter describes the resulting vector.
|
||
|
|
|
||
|
|
|
||
|
|
=head1 SEE ALSO
|
||
|
|
|
||
|
|
L<BH>
|