Point class

A 2D point class for coordinate operations.

Constructors

Point(double x, double y)
Creates a point with the given x and y coordinates.
const
Point.fromList(List<num> list)
Creates a point from a List x, y.
factory
Point.fromMap(Map<String, dynamic> map)
Creates a point from a Map with 'x' and 'y' keys.
factory
Point.fromPolar(double radius, double angle)
Creates a point from polar coordinates.
factory

Properties

angle → double
Returns the angle of this point relative to the origin.
no setter
hashCode → int
The hash code for this object.
no setteroverride
hasNaN → bool
Returns true if this point has NaN values.
no setter
isFinite → bool
Returns true if this point is finite.
no setter
magnitude → double
Returns the magnitude (length) of this point as a vector.
no setter
normalized → Point
Returns a normalized version of this point (unit vector).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
squaredMagnitude → double
Returns the squared magnitude of this point as a vector.
no setter
x → double
The x coordinate.
final
y → double
The y coordinate.
final

Methods

clamp({double? minX, double? maxX, double? minY, double? maxY}) → Point
Clamps this point to the given bounds.
copyWith({double? x, double? y}) → Point
Returns a copy with updated values.
cross(Point other) → double
Returns the cross product (z-component) with another point.
distanceTo(Point other) → double
Returns the Euclidean distance to another point.
dot(Point other) → double
Returns the dot product with another point.
lerp(Point other, double t) → Point
Linearly interpolates between this point and another.
manhattanDistanceTo(Point other) → double
Returns the Manhattan distance to another point.
midpointTo(Point other) → Point
Returns the midpoint between this point and another.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rotate(double angle) → Point
Returns a rotated version of this point around the origin.
rotateAround(Point center, double angle) → Point
Returns a rotated version around a center point.
squaredDistanceTo(Point other) → double
Returns the squared distance to another point. More efficient than distanceTo when comparing distances.
toList() → List<double>
Converts to a List x, y.
toMap() → Map<String, double>
Converts to a Map.
toString() → String
A string representation of this object.
override

Operators

operator *(double scalar) → Point
Multiplies the point by a scalar.
operator +(Point other) → Point
Adds two points.
operator -(Point other) → Point
Subtracts two points.
operator /(double scalar) → Point
Divides the point by a scalar.
operator ==(Object other) → bool
The equality operator.
override
operator unary-() → Point
Negates the point.

Constants

zero → const Point
Creates a point at the origin (0, 0).