Point class - dart:math library (original) (raw)
Point<T extends num> class
A utility class for representing two-dimensional positions.
Example:
var leftTop = const Point(0, 0);
var rightBottom = const Point(200, 400);
Legacy: New usages of Point are discouraged.
- If you are using the
Point
class withdart:html
, we recommend migrating topackage:web
. To learn how and why to migrate, check out the migration guide. - If you want to combine an
x
andy
coordinate, consider using a record. Depending on how you will use it, this could look likevar point = (x, y)
orvar point = (x: x, y: y)
. - If you want to perform vector operations, like vector addition or scalar multiplication, consider using a dedicated vector math library, such as package:vector_math.
- If you are developing a Flutter application or package, consider using theOffsettype from
dart:ui
.
Constructors
Point(T x, T y)
Creates a point with the provided x
and y
coordinates.
const
Properties
The hash code for this object.
no setteroverride
Get the straight line (Euclidean) distance between the origin (0, 0) and this point.
no setter
A representation of the runtime type of the object.
no setterinherited
x → T
final
y → T
final
Methods
distanceTo(Point<T> other)→ double
Returns the distance between this
and other
.
noSuchMethod(Invocation invocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
squaredDistanceTo(Point<T> other)→ T
Returns the squared distance between this
and other
.
A string representation of this object.
override
Operators
operator *(num factor)→ Point<T>
Scale this point by factor
as if it were a vector.
operator +(Point<T> other)→ Point<T>
Add other
to this
, as if both points were vectors.
operator -(Point<T> other)→ Point<T>
Subtract other
from this
, as if both points were vectors.
operator ==(Object other)→ bool
Whether other
is a point with the same coordinates as this point.
override