PolarCoord.fromPoints constructor

PolarCoord.fromPoints(
  1. Point<double> origin,
  2. Point<double> point
)

Implementation

factory PolarCoord.fromPoints(Point<double> origin, Point<double> point) {
  // Subtract the origin from the point to get the vector from the origin
  // to the point.
  final Point<double> vectorPoint = point - origin;
  final Offset vector = Offset(vectorPoint.x, vectorPoint.y);

  // 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,
  );
}