Program Listing for File math.cc¶
↰ Return to documentation for file (src/math.cc
)
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* The ACME project *
* *
* Copyright (c) 2020, Davide Stocco and Enrico Bertolazzi. *
* *
* The ACME project and its components are supplied under the terms of *
* the open source BSD 2-Clause License. The contents of the ACME *
* project and its components may not be copied or disclosed except in *
* accordance with the terms of the BSD 2-Clause License. *
* *
* URL: https://opensource.org/licenses/BSD-2-Clause *
* *
* Davide Stocco *
* Department of Industrial Engineering *
* University of Trento *
* e-mail: davide.stocco@unitn.it *
* *
* Enrico Bertolazzi *
* Department of Industrial Engineering *
* University of Trento *
* e-mail: enrico.bertolazzi@unitn.it *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#include "acme.hh"
namespace acme
{
/*\
| __ __ _ _
| | \/ | __ _| |_| |__
| | |\/| |/ _` | __| '_ \
| | | | | (_| | |_| | | |
| |_| |_|\__,_|\__|_| |_|
|
\*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool
IsApprox(
real value0_in,
real value1_in,
real tolerance)
{
return std::abs(value0_in-value1_in) < tolerance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void
Transform(
vec3 & vector,
affine const & matrix)
{
vector = matrix.linear() * vector;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
real
Angle(
vec3 const & vector0_in,
vec3 const & vector1_in
)
{
return std::acos(vector0_in.dot(vector1_in)/(vector0_in.norm()*vector1_in.norm()));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
} // namespace acme
#endif