mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-02 09:06:58 +00:00
lottie/vector: add angle api to VLine class
Change-Id: Iaa839e5a4e7a0517c7a9a01cb8e0de972dba95c6
This commit is contained in:
@@ -21,7 +21,7 @@ public:
|
||||
void splitAtLength(float length, VLine &left, VLine &right) const;
|
||||
VPointF p1() const { return {mX1, mY1}; }
|
||||
VPointF p2() const { return {mX2, mY2}; }
|
||||
|
||||
float angle() const;
|
||||
static float length(float x1, float y1, float x2, float y2);
|
||||
|
||||
private:
|
||||
@@ -31,6 +31,15 @@ private:
|
||||
float mY2{0};
|
||||
};
|
||||
|
||||
inline float VLine::angle() const
|
||||
{
|
||||
const float dx = mX2 - mX1;
|
||||
const float dy = mY2 - mY1;
|
||||
|
||||
const float theta = std::atan2(dy, dx) * 180.0 / M_PI;
|
||||
return theta;
|
||||
}
|
||||
|
||||
// approximate sqrt(x*x + y*y) using alpha max plus beta min algorithm.
|
||||
// With alpha = 1, beta = 3/8, giving results with the largest error less
|
||||
// than 7% compared to the exact value.
|
||||
@@ -62,4 +71,4 @@ inline void VLine::splitAtLength(float lengthAt, VLine &left, VLine &right) cons
|
||||
right.mY2 = mY2;
|
||||
}
|
||||
|
||||
#endif //VLINE_H
|
||||
#endif //VLINE_H
|
||||
|
||||
Reference in New Issue
Block a user