示例#1
0
Vec2D Vec2D::projection(Vec2D const& other) const
{
  Vec2D direction = other.unit();
  return direction.scalei(dot(direction));
}
示例#2
0
文件: vec2d.cpp 项目: bzar/2dshooter
// n.projection(m) = m, m.reverseProjection(n.unit()) = n
Vec2D Vec2D::reverseProjection(const Vec2D &other) const
{
  Vec2D nu = other.unit();
  float l = length();
  return nu.scalei(l / nu.dot(scale(1.0f/l)));
}
示例#3
0
Vec2D& Vec2D::projectioni(Vec2D const& other)
{
  Vec2D direction = other.unit();
  return assign(direction.scalei(dot(direction)));
}
示例#4
0
文件: vec2d.cpp 项目: bzar/2dshooter
Vec2D &Vec2D::reverseProjectioni(const Vec2D &other)
{
  Vec2D nu = other.unit();
  float l = length();
  return assign(nu.scalei(l / nu.dot(scalei(1.0f/l))));
}