mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-02 16:22:40 -06:00
Merge continued
git-svn-id: svn://ultimatepp.org/upp/trunk@10263 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
adf46bd64e
commit
2e4b276e07
3860 changed files with 1161787 additions and 438 deletions
51
uppdev/ScanLine/Math.cpp
Normal file
51
uppdev/ScanLine/Math.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#include "ScanLine.h"
|
||||
|
||||
double SquareDist(const Pointf& p1, const Pointf& p2)
|
||||
{
|
||||
return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
|
||||
}
|
||||
|
||||
Pointf Mid(const Pointf& a, const Pointf& b)
|
||||
{
|
||||
return 0.5 * (a + b);
|
||||
}
|
||||
|
||||
Pointf Ortogonal(const Pointf& p)
|
||||
{
|
||||
return Pointf(-p.y, p.x);
|
||||
}
|
||||
|
||||
double SquareLength(const Pointf& p)
|
||||
{
|
||||
return p.x * p.x + p.y * p.y;
|
||||
}
|
||||
|
||||
double Length(const Pointf& p)
|
||||
{
|
||||
return sqrt(SquareLength(p));
|
||||
}
|
||||
|
||||
double Bearing(const Pointf& p)
|
||||
{
|
||||
return atan2(p.y, p.x);
|
||||
}
|
||||
|
||||
double Distance(const Pointf& p1, const Pointf& p2)
|
||||
{
|
||||
return Length(p1 - p2);
|
||||
}
|
||||
|
||||
double SquareDistance(const Pointf& p1, const Pointf& p2)
|
||||
{
|
||||
return SquareLength(p1 - p2);
|
||||
}
|
||||
|
||||
Pointf PolarPointf(double a)
|
||||
{
|
||||
return Pointf(cos(a), sin(a));
|
||||
}
|
||||
|
||||
Pointf Polar(const Pointf& p, double r, double a)
|
||||
{
|
||||
return p + r * PolarPointf(a);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue