Point class
An immutable 2D point (or vector) with x and y coordinates.
Supports arithmetic operators for vector math:
+/-for addition and subtraction*//for scalar multiplication and division%for cross product
final p = Point(3, 4);
print(p.magnitude); // 5.0
print(p.normalized); // Point(0.6, 0.8)
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- magnitude → double
-
Distance from origin (vector magnitude)
no setter
- normalized → Point
-
Unit vector (magnitude 1) in same direction
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- x → double
-
X coordinate.
final
- y → double
-
Y coordinate.
final
Methods
-
angleTo(
Point other) → double -
Angle from this point to
otherin radians -
distanceTo(
Point other) → double -
Euclidean distance from this point to
other. -
dot(
Point other) → double -
Dot product with
other -
midPointTo(
Point other) → Point -
Midpoint between this point and
other -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pointAtAngle(
double radius, double angle) → Point - generates a point at a specified angle and distance from a center point
-
pointAtDistance(
double distance, [double angle = 0]) → Point - Get the point at a distance to this point
-
rotate(
double deg) → Point -
rotate the point by
degdegrees -
scale(
double factor) → Point - move the point my scale factor
-
toString(
) → String -
A string representation of this object.
override
-
translate(
double x, double y) → Point -
translate the point with
xin horizontally andyvertically
Operators
-
operator %(
Point other) → double -
Cross product of this point and
other(2D pseudo cross product). -
operator *(
double scalar) → Point -
Multiply this point by
scalar(scalar multiplication). -
operator +(
Point other) → Point -
Add
otherto this point (vector addition). -
operator -(
Point other) → Point -
Subtract
otherfrom this point (vector subtraction). -
operator /(
double scalar) → Point -
Divide this point by
scalar(scalar division). -
operator ==(
Object other) → bool -
The equality operator.
override