I have a small request to add some math functions to BaseBlamTypesPc. Here are a few I have written into OS and use currently. I am working on an angle distance one and I'm sure there will be other very common ones used in 3D math:
real_point3d(applies to 2d also without z):
Code:
API_INLINE real Distance(real_point3d& rp) const
{
real_point3d d = {
this->x - rp.x,
this->y - rp.y,
this->z - rp.z
};
return (real)sqrt( d.x*d.x + d.y*d.y + d.z*d.z );
}
real_vector3d:
Code:
API_INLINE real Dot(real_vector3d& v) const
{ return (real)( this->i*v.i + this->j*v.j + this->k*v.k ); }
API_INLINE real_vector3d Cross(real_vector3d& v) const
{
real_vector3d cross = {
this->j * v.k - this->k * v.j,
this->k * v.i - this->i * v.k,
this->i * v.j - this->j * v.i
};
return cross
}
Bookmarks