PolarCoord.fromPoints constructor
Implementation
factory PolarCoord.fromPoints(Point origin, Point point) {
// Subtract the origin from the point to get the vector from the origin
// to the point.
final vectorPoint = point - origin;
final vector = Offset(vectorPoint.x as double, vectorPoint.y as double);
// The polar coordinate is the angle the vector forms with the x-axis, and
// the distance of the vector.
return PolarCoord(
vector.direction,
vector.distance,
Offset(origin.x as double, origin.y as double),
Offset(point.x as double, point.y as double),
);
}