2012-03-09 22:44:36 -04:00
|
|
|
/*
|
|
|
|
* vector3.cpp
|
|
|
|
* Copyright (C) Andrew Tridgell 2012
|
|
|
|
*
|
|
|
|
* This file is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-09-27 17:45:12 -03:00
|
|
|
#pragma GCC optimize("O2")
|
2015-10-19 18:27:22 -03:00
|
|
|
|
2012-03-09 22:44:36 -04:00
|
|
|
#include "AP_Math.h"
|
2020-04-20 10:45:33 -03:00
|
|
|
#include <AP_InternalError/AP_InternalError.h>
|
2012-03-09 22:44:36 -04:00
|
|
|
|
|
|
|
// rotate a vector by a standard rotation, attempting
|
|
|
|
// to use the minimum number of floating point operations
|
|
|
|
template <typename T>
|
|
|
|
void Vector3<T>::rotate(enum Rotation rotation)
|
|
|
|
{
|
|
|
|
T tmp;
|
|
|
|
switch (rotation) {
|
|
|
|
case ROTATION_NONE:
|
|
|
|
return;
|
|
|
|
case ROTATION_YAW_45: {
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = HALF_SQRT_2*(float)(x - y);
|
|
|
|
y = HALF_SQRT_2*(float)(x + y);
|
2012-03-09 22:44:36 -04:00
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_YAW_90: {
|
|
|
|
tmp = x; x = -y; y = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_YAW_135: {
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = -HALF_SQRT_2*(float)(x + y);
|
|
|
|
y = HALF_SQRT_2*(float)(x - y);
|
2012-03-09 22:44:36 -04:00
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_YAW_180:
|
|
|
|
x = -x; y = -y;
|
|
|
|
return;
|
|
|
|
case ROTATION_YAW_225: {
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = HALF_SQRT_2*(float)(y - x);
|
|
|
|
y = -HALF_SQRT_2*(float)(x + y);
|
2012-03-09 22:44:36 -04:00
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_YAW_270: {
|
|
|
|
tmp = x; x = y; y = -tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_YAW_315: {
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = HALF_SQRT_2*(float)(x + y);
|
|
|
|
y = HALF_SQRT_2*(float)(y - x);
|
2012-03-09 22:44:36 -04:00
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180: {
|
|
|
|
y = -y; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180_YAW_45: {
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = HALF_SQRT_2*(float)(x + y);
|
|
|
|
y = HALF_SQRT_2*(float)(x - y);
|
2012-03-09 22:44:36 -04:00
|
|
|
x = tmp; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180_YAW_90: {
|
|
|
|
tmp = x; x = y; y = tmp; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180_YAW_135: {
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = HALF_SQRT_2*(float)(y - x);
|
|
|
|
y = HALF_SQRT_2*(float)(y + x);
|
2012-03-09 22:44:36 -04:00
|
|
|
x = tmp; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_PITCH_180: {
|
|
|
|
x = -x; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180_YAW_225: {
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = -HALF_SQRT_2*(float)(x + y);
|
|
|
|
y = HALF_SQRT_2*(float)(y - x);
|
2012-03-09 22:44:36 -04:00
|
|
|
x = tmp; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180_YAW_270: {
|
|
|
|
tmp = x; x = -y; y = -tmp; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180_YAW_315: {
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = HALF_SQRT_2*(float)(x - y);
|
|
|
|
y = -HALF_SQRT_2*(float)(x + y);
|
2012-03-09 22:44:36 -04:00
|
|
|
x = tmp; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
2013-01-13 02:26:48 -04:00
|
|
|
case ROTATION_ROLL_90: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_YAW_45: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = HALF_SQRT_2*(float)(x - y);
|
|
|
|
y = HALF_SQRT_2*(float)(x + y);
|
2013-01-13 02:26:48 -04:00
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_YAW_90: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
|
|
|
tmp = x; x = -y; y = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_YAW_135: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = -HALF_SQRT_2*(float)(x + y);
|
|
|
|
y = HALF_SQRT_2*(float)(x - y);
|
2013-01-13 02:26:48 -04:00
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_270: {
|
|
|
|
tmp = z; z = -y; y = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_270_YAW_45: {
|
|
|
|
tmp = z; z = -y; y = tmp;
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = HALF_SQRT_2*(float)(x - y);
|
|
|
|
y = HALF_SQRT_2*(float)(x + y);
|
2013-01-13 02:26:48 -04:00
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_270_YAW_90: {
|
|
|
|
tmp = z; z = -y; y = tmp;
|
|
|
|
tmp = x; x = -y; y = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_270_YAW_135: {
|
|
|
|
tmp = z; z = -y; y = tmp;
|
2015-05-03 01:44:26 -03:00
|
|
|
tmp = -HALF_SQRT_2*(float)(x + y);
|
|
|
|
y = HALF_SQRT_2*(float)(x - y);
|
2013-01-13 02:26:48 -04:00
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_PITCH_90: {
|
|
|
|
tmp = z; z = -x; x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_PITCH_270: {
|
|
|
|
tmp = z; z = x; x = -tmp;
|
|
|
|
return;
|
|
|
|
}
|
2013-08-26 10:02:48 -03:00
|
|
|
case ROTATION_PITCH_180_YAW_90: {
|
|
|
|
z = -z;
|
|
|
|
tmp = -x; x = -y; y = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_PITCH_180_YAW_270: {
|
|
|
|
x = -x; z = -z;
|
|
|
|
tmp = x; x = y; y = -tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_PITCH_90: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
|
|
|
tmp = z; z = -x; x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180_PITCH_90: {
|
|
|
|
y = -y; z = -z;
|
|
|
|
tmp = z; z = -x; x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_270_PITCH_90: {
|
|
|
|
tmp = z; z = -y; y = tmp;
|
|
|
|
tmp = z; z = -x; x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_PITCH_180: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
|
|
|
x = -x; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_270_PITCH_180: {
|
|
|
|
tmp = z; z = -y; y = tmp;
|
|
|
|
x = -x; z = -z;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_PITCH_270: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
|
|
|
tmp = z; z = x; x = -tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_180_PITCH_270: {
|
|
|
|
y = -y; z = -z;
|
|
|
|
tmp = z; z = x; x = -tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_270_PITCH_270: {
|
|
|
|
tmp = z; z = -y; y = tmp;
|
|
|
|
tmp = z; z = x; x = -tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_PITCH_180_YAW_90: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
|
|
|
x = -x; z = -z;
|
|
|
|
tmp = x; x = -y; y = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_YAW_270: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
|
|
|
tmp = x; x = y; y = -tmp;
|
|
|
|
return;
|
|
|
|
}
|
2015-12-28 14:23:18 -04:00
|
|
|
case ROTATION_ROLL_90_PITCH_68_YAW_293: {
|
2014-11-24 17:17:15 -04:00
|
|
|
float tmpx = x;
|
2014-11-22 01:09:16 -04:00
|
|
|
float tmpy = y;
|
|
|
|
float tmpz = z;
|
2014-12-31 19:20:18 -04:00
|
|
|
x = 0.143039f * tmpx + 0.368776f * tmpy + -0.918446f * tmpz;
|
|
|
|
y = -0.332133f * tmpx + -0.856289f * tmpy + -0.395546f * tmpz;
|
|
|
|
z = -0.932324f * tmpx + 0.361625f * tmpy + 0.000000f * tmpz;
|
2014-11-22 01:09:16 -04:00
|
|
|
return;
|
|
|
|
}
|
2018-03-08 19:08:18 -04:00
|
|
|
case ROTATION_PITCH_315: {
|
|
|
|
tmp = HALF_SQRT_2*(float)(x - z);
|
|
|
|
z = HALF_SQRT_2*(float)(x + z);
|
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case ROTATION_ROLL_90_PITCH_315: {
|
|
|
|
tmp = z; z = y; y = -tmp;
|
|
|
|
tmp = HALF_SQRT_2*(float)(x - z);
|
|
|
|
z = HALF_SQRT_2*(float)(x + z);
|
|
|
|
x = tmp;
|
|
|
|
return;
|
|
|
|
}
|
2019-04-09 07:03:36 -03:00
|
|
|
case ROTATION_PITCH_7: {
|
|
|
|
const float sin_pitch = 0.12186934340514748f; // sinf(pitch);
|
|
|
|
const float cos_pitch = 0.992546151641322f; // cosf(pitch);
|
|
|
|
float tmpx = x;
|
|
|
|
float tmpz = z;
|
|
|
|
x = cos_pitch * tmpx + sin_pitch * tmpz;
|
|
|
|
z = -sin_pitch * tmpx + cos_pitch * tmpz;
|
|
|
|
return;
|
|
|
|
}
|
2020-04-20 10:45:33 -03:00
|
|
|
case ROTATION_CUSTOM:
|
|
|
|
// Error: caller must perform custom rotations via matrix multiplication
|
2020-04-29 21:40:46 -03:00
|
|
|
INTERNAL_ERROR(AP_InternalError::error_t::flow_of_control);
|
2018-03-08 22:17:29 -04:00
|
|
|
return;
|
2020-04-20 10:45:33 -03:00
|
|
|
case ROTATION_MAX:
|
|
|
|
break;
|
2012-03-09 22:44:36 -04:00
|
|
|
}
|
2020-04-20 10:45:33 -03:00
|
|
|
// rotation invalid
|
2020-04-29 21:40:46 -03:00
|
|
|
INTERNAL_ERROR(AP_InternalError::error_t::bad_rotation);
|
2012-03-09 22:44:36 -04:00
|
|
|
}
|
|
|
|
|
2015-04-21 00:37:35 -03:00
|
|
|
template <typename T>
|
|
|
|
void Vector3<T>::rotate_inverse(enum Rotation rotation)
|
|
|
|
{
|
|
|
|
Vector3<T> x_vec(1.0f,0.0f,0.0f);
|
|
|
|
Vector3<T> y_vec(0.0f,1.0f,0.0f);
|
|
|
|
Vector3<T> z_vec(0.0f,0.0f,1.0f);
|
|
|
|
|
|
|
|
x_vec.rotate(rotation);
|
|
|
|
y_vec.rotate(rotation);
|
|
|
|
z_vec.rotate(rotation);
|
|
|
|
|
|
|
|
Matrix3<T> M(
|
|
|
|
x_vec.x, y_vec.x, z_vec.x,
|
|
|
|
x_vec.y, y_vec.y, z_vec.y,
|
|
|
|
x_vec.z, y_vec.z, z_vec.z
|
|
|
|
);
|
|
|
|
|
|
|
|
(*this) = M.mul_transpose(*this);
|
|
|
|
}
|
|
|
|
|
2012-03-23 00:59:06 -03:00
|
|
|
// vector cross product
|
2012-03-22 07:12:36 -03:00
|
|
|
template <typename T>
|
|
|
|
Vector3<T> Vector3<T>::operator %(const Vector3<T> &v) const
|
|
|
|
{
|
|
|
|
Vector3<T> temp(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// dot product
|
|
|
|
template <typename T>
|
|
|
|
T Vector3<T>::operator *(const Vector3<T> &v) const
|
2012-08-17 03:20:14 -03:00
|
|
|
{
|
|
|
|
return x*v.x + y*v.y + z*v.z;
|
|
|
|
}
|
2012-03-22 07:12:36 -03:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
float Vector3<T>::length(void) const
|
|
|
|
{
|
2016-04-16 06:58:46 -03:00
|
|
|
return norm(x, y, z);
|
2012-03-22 07:12:36 -03:00
|
|
|
}
|
|
|
|
|
2013-04-11 21:04:18 -03:00
|
|
|
template <typename T>
|
|
|
|
Vector3<T> &Vector3<T>::operator *=(const T num)
|
|
|
|
{
|
|
|
|
x*=num; y*=num; z*=num;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> &Vector3<T>::operator /=(const T num)
|
|
|
|
{
|
|
|
|
x /= num; y /= num; z /= num;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> &Vector3<T>::operator -=(const Vector3<T> &v)
|
|
|
|
{
|
|
|
|
x -= v.x; y -= v.y; z -= v.z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
bool Vector3<T>::is_nan(void) const
|
|
|
|
{
|
|
|
|
return isnan(x) || isnan(y) || isnan(z);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
bool Vector3<T>::is_inf(void) const
|
|
|
|
{
|
|
|
|
return isinf(x) || isinf(y) || isinf(z);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> &Vector3<T>::operator +=(const Vector3<T> &v)
|
|
|
|
{
|
|
|
|
x+=v.x; y+=v.y; z+=v.z;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> Vector3<T>::operator /(const T num) const
|
|
|
|
{
|
|
|
|
return Vector3<T>(x/num, y/num, z/num);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> Vector3<T>::operator *(const T num) const
|
|
|
|
{
|
|
|
|
return Vector3<T>(x*num, y*num, z*num);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> Vector3<T>::operator -(const Vector3<T> &v) const
|
|
|
|
{
|
|
|
|
return Vector3<T>(x-v.x, y-v.y, z-v.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> Vector3<T>::operator +(const Vector3<T> &v) const
|
|
|
|
{
|
|
|
|
return Vector3<T>(x+v.x, y+v.y, z+v.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> Vector3<T>::operator -(void) const
|
|
|
|
{
|
|
|
|
return Vector3<T>(-x,-y,-z);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
bool Vector3<T>::operator ==(const Vector3<T> &v) const
|
|
|
|
{
|
2015-05-04 23:35:31 -03:00
|
|
|
return (is_equal(x,v.x) && is_equal(y,v.y) && is_equal(z,v.z));
|
2013-04-11 21:04:18 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
bool Vector3<T>::operator !=(const Vector3<T> &v) const
|
|
|
|
{
|
2015-05-04 23:35:31 -03:00
|
|
|
return (!is_equal(x,v.x) || !is_equal(y,v.y) || !is_equal(z,v.z));
|
2013-04-11 21:04:18 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
float Vector3<T>::angle(const Vector3<T> &v2) const
|
|
|
|
{
|
2018-09-11 05:57:33 -03:00
|
|
|
const float len = this->length() * v2.length();
|
2015-12-31 21:26:52 -04:00
|
|
|
if (len <= 0) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
2018-09-11 05:57:33 -03:00
|
|
|
const float cosv = ((*this)*v2) / len;
|
2015-12-31 21:26:52 -04:00
|
|
|
if (fabsf(cosv) >= 1) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
return acosf(cosv);
|
2013-04-11 21:04:18 -03:00
|
|
|
}
|
|
|
|
|
2013-07-19 19:13:34 -03:00
|
|
|
// multiplication of transpose by a vector
|
|
|
|
template <typename T>
|
|
|
|
Vector3<T> Vector3<T>::operator *(const Matrix3<T> &m) const
|
|
|
|
{
|
|
|
|
return Vector3<T>(*this * m.colx(),
|
|
|
|
*this * m.coly(),
|
|
|
|
*this * m.colz());
|
|
|
|
}
|
|
|
|
|
|
|
|
// multiply a column vector by a row vector, returning a 3x3 matrix
|
|
|
|
template <typename T>
|
|
|
|
Matrix3<T> Vector3<T>::mul_rowcol(const Vector3<T> &v2) const
|
|
|
|
{
|
|
|
|
const Vector3<T> v1 = *this;
|
|
|
|
return Matrix3<T>(v1.x * v2.x, v1.x * v2.y, v1.x * v2.z,
|
|
|
|
v1.y * v2.x, v1.y * v2.y, v1.y * v2.z,
|
|
|
|
v1.z * v2.x, v1.z * v2.y, v1.z * v2.z);
|
|
|
|
}
|
|
|
|
|
2017-08-30 06:25:18 -03:00
|
|
|
// distance from the tip of this vector to a line segment specified by two vectors
|
|
|
|
template <typename T>
|
|
|
|
float Vector3<T>::distance_to_segment(const Vector3<T> &seg_start, const Vector3<T> &seg_end) const
|
|
|
|
{
|
|
|
|
// triangle side lengths
|
2018-09-11 05:57:33 -03:00
|
|
|
const float a = (*this-seg_start).length();
|
|
|
|
const float b = (seg_start-seg_end).length();
|
|
|
|
const float c = (seg_end-*this).length();
|
2017-08-30 06:25:18 -03:00
|
|
|
|
|
|
|
// protect against divide by zero later
|
2018-11-03 19:50:10 -03:00
|
|
|
if (::is_zero(b)) {
|
2017-08-30 06:25:18 -03:00
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
// semiperimeter of triangle
|
2018-09-11 05:57:33 -03:00
|
|
|
const float s = (a+b+c) * 0.5f;
|
2017-08-30 06:25:18 -03:00
|
|
|
|
|
|
|
float area_squared = s*(s-a)*(s-b)*(s-c);
|
|
|
|
// area must be constrained above 0 because a triangle could have 3 points could be on a line and float rounding could push this under 0
|
|
|
|
if (area_squared < 0.0f) {
|
|
|
|
area_squared = 0.0f;
|
|
|
|
}
|
2018-09-11 05:57:33 -03:00
|
|
|
const float area = safe_sqrt(area_squared);
|
2017-08-30 06:25:18 -03:00
|
|
|
return 2.0f*area/b;
|
|
|
|
}
|
|
|
|
|
2016-11-08 21:10:31 -04:00
|
|
|
// define for float
|
2012-03-09 22:44:36 -04:00
|
|
|
template void Vector3<float>::rotate(enum Rotation);
|
2015-04-21 00:37:35 -03:00
|
|
|
template void Vector3<float>::rotate_inverse(enum Rotation);
|
2012-03-22 07:12:36 -03:00
|
|
|
template float Vector3<float>::length(void) const;
|
|
|
|
template Vector3<float> Vector3<float>::operator %(const Vector3<float> &v) const;
|
|
|
|
template float Vector3<float>::operator *(const Vector3<float> &v) const;
|
2013-07-19 19:13:34 -03:00
|
|
|
template Vector3<float> Vector3<float>::operator *(const Matrix3<float> &m) const;
|
|
|
|
template Matrix3<float> Vector3<float>::mul_rowcol(const Vector3<float> &v) const;
|
2013-04-11 21:04:18 -03:00
|
|
|
template Vector3<float> &Vector3<float>::operator *=(const float num);
|
|
|
|
template Vector3<float> &Vector3<float>::operator /=(const float num);
|
|
|
|
template Vector3<float> &Vector3<float>::operator -=(const Vector3<float> &v);
|
|
|
|
template Vector3<float> &Vector3<float>::operator +=(const Vector3<float> &v);
|
|
|
|
template Vector3<float> Vector3<float>::operator /(const float num) const;
|
|
|
|
template Vector3<float> Vector3<float>::operator *(const float num) const;
|
|
|
|
template Vector3<float> Vector3<float>::operator +(const Vector3<float> &v) const;
|
|
|
|
template Vector3<float> Vector3<float>::operator -(const Vector3<float> &v) const;
|
|
|
|
template Vector3<float> Vector3<float>::operator -(void) const;
|
|
|
|
template bool Vector3<float>::operator ==(const Vector3<float> &v) const;
|
|
|
|
template bool Vector3<float>::operator !=(const Vector3<float> &v) const;
|
|
|
|
template bool Vector3<float>::is_nan(void) const;
|
|
|
|
template bool Vector3<float>::is_inf(void) const;
|
|
|
|
template float Vector3<float>::angle(const Vector3<float> &v) const;
|
2017-08-30 06:25:18 -03:00
|
|
|
template float Vector3<float>::distance_to_segment(const Vector3<float> &seg_start, const Vector3<float> &seg_end) const;
|
2014-04-03 19:44:56 -03:00
|
|
|
|
2016-11-08 21:10:31 -04:00
|
|
|
// define needed ops for Vector3l
|
|
|
|
template Vector3<int32_t> &Vector3<int32_t>::operator +=(const Vector3<int32_t> &v);
|
|
|
|
|
2014-04-03 19:44:56 -03:00
|
|
|
template void Vector3<double>::rotate(enum Rotation);
|
2015-04-21 00:37:35 -03:00
|
|
|
template void Vector3<double>::rotate_inverse(enum Rotation);
|
2014-04-03 19:44:56 -03:00
|
|
|
template float Vector3<double>::length(void) const;
|
|
|
|
template Vector3<double> Vector3<double>::operator %(const Vector3<double> &v) const;
|
|
|
|
template double Vector3<double>::operator *(const Vector3<double> &v) const;
|
|
|
|
template Vector3<double> Vector3<double>::operator *(const Matrix3<double> &m) const;
|
|
|
|
template Matrix3<double> Vector3<double>::mul_rowcol(const Vector3<double> &v) const;
|
|
|
|
template Vector3<double> &Vector3<double>::operator *=(const double num);
|
|
|
|
template Vector3<double> &Vector3<double>::operator /=(const double num);
|
|
|
|
template Vector3<double> &Vector3<double>::operator -=(const Vector3<double> &v);
|
|
|
|
template Vector3<double> &Vector3<double>::operator +=(const Vector3<double> &v);
|
|
|
|
template Vector3<double> Vector3<double>::operator /(const double num) const;
|
|
|
|
template Vector3<double> Vector3<double>::operator *(const double num) const;
|
|
|
|
template Vector3<double> Vector3<double>::operator +(const Vector3<double> &v) const;
|
|
|
|
template Vector3<double> Vector3<double>::operator -(const Vector3<double> &v) const;
|
|
|
|
template Vector3<double> Vector3<double>::operator -(void) const;
|
|
|
|
template bool Vector3<double>::operator ==(const Vector3<double> &v) const;
|
|
|
|
template bool Vector3<double>::operator !=(const Vector3<double> &v) const;
|
|
|
|
template bool Vector3<double>::is_nan(void) const;
|
|
|
|
template bool Vector3<double>::is_inf(void) const;
|