Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
GrTriangulator::Line Struct Reference

#include <GrTriangulator.h>

Public Member Functions

 Line (double a, double b, double c)
 
 Line (Vertex *p, Vertex *q)
 
 Line (const SkPoint &p, const SkPoint &q)
 
double dist (const SkPoint &p) const
 
Line operator* (double v) const
 
double magSq () const
 
void normalize ()
 
bool nearParallel (const Line &o) const
 
bool intersect (const Line &other, SkPoint *point) const
 

Public Attributes

double fA
 
double fB
 
double fC
 

Detailed Description

Definition at line 358 of file GrTriangulator.h.

Constructor & Destructor Documentation

◆ Line() [1/3]

GrTriangulator::Line::Line ( double  a,
double  b,
double  c 
)
inline

Definition at line 359 of file GrTriangulator.h.

359: fA(a), fB(b), fC(c) {}
static bool b
struct MyStruct a[10]

◆ Line() [2/3]

GrTriangulator::Line::Line ( Vertex p,
Vertex q 
)
inline

Definition at line 360 of file GrTriangulator.h.

360: Line(p->fPoint, q->fPoint) {}
Line(double a, double b, double c)

◆ Line() [3/3]

GrTriangulator::Line::Line ( const SkPoint p,
const SkPoint q 
)
inline

Definition at line 361 of file GrTriangulator.h.

362 : fA(static_cast<double>(q.fY) - p.fY) // a = dY
363 , fB(static_cast<double>(p.fX) - q.fX) // b = -dX
364 , fC(static_cast<double>(p.fY) * q.fX - // c = cross(q, p)
365 static_cast<double>(p.fX) * q.fY) {}
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

Member Function Documentation

◆ dist()

double GrTriangulator::Line::dist ( const SkPoint p) const
inline

Definition at line 366 of file GrTriangulator.h.

366{ return fA * p.fX + fB * p.fY + fC; }

◆ intersect()

bool GrTriangulator::Line::intersect ( const Line other,
SkPoint point 
) const

Definition at line 155 of file GrTriangulator.cpp.

155 {
156 double denom = fA * other.fB - fB * other.fA;
157 if (denom == 0.0) {
158 return false;
159 }
160 double scale = 1.0 / denom;
161 point->fX = double_to_clamped_scalar((fB * other.fC - other.fB * fC) * scale);
162 point->fY = double_to_clamped_scalar((other.fA * fC - fA * other.fC) * scale);
163 round(point);
164 return point->isFinite();
165}
static void round(SkPoint *p)
static SkScalar double_to_clamped_scalar(double d)
const Scalar scale
bool isFinite() const
Definition: SkPoint_impl.h:412

◆ magSq()

double GrTriangulator::Line::magSq ( ) const
inline

Definition at line 368 of file GrTriangulator.h.

368{ return fA * fA + fB * fB; }

◆ nearParallel()

bool GrTriangulator::Line::nearParallel ( const Line o) const
inline

Definition at line 379 of file GrTriangulator.h.

379 {
380 return fabs(o.fA - fA) < 0.00001 && fabs(o.fB - fB) < 0.00001;
381 }

◆ normalize()

void GrTriangulator::Line::normalize ( )
inline

Definition at line 369 of file GrTriangulator.h.

369 {
370 double len = sqrt(this->magSq());
371 if (len == 0.0) {
372 return;
373 }
374 double scale = 1.0f / len;
375 fA *= scale;
376 fB *= scale;
377 fC *= scale;
378 }
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition: SkVx.h:706
double magSq() const

◆ operator*()

Line GrTriangulator::Line::operator* ( double  v) const
inline

Definition at line 367 of file GrTriangulator.h.

367{ return Line(fA * v, fB * v, fC * v); }

Member Data Documentation

◆ fA

double GrTriangulator::Line::fA

Definition at line 385 of file GrTriangulator.h.

◆ fB

double GrTriangulator::Line::fB

Definition at line 385 of file GrTriangulator.h.

◆ fC

double GrTriangulator::Line::fC

Definition at line 385 of file GrTriangulator.h.


The documentation for this struct was generated from the following files: