Point class

Class Point represents a point in two or three-dimensional space. The point coordinates are represented by x, y and optionally z.

The Point class supports a wide variety of operations such as basic arithmetic operations, transformation operations (like rotation and scaling), distance and angle calculations, conversion to/from polar coordinates, and geometric operations related to lines, triangles, circles, and polygons.

Inheritance
Available extensions

Constructors

Point(dynamic x, dynamic y, [dynamic z])
Constructor for creating a new Point.
Point.fromList(List coords)
Constructs a new Point from a list of numbers.
factory
Point.fromPolarCoordinates(num r, num theta, [Point? origin])
Create a point and sets the coordinates of the point given polar coordinates r and theta (in radians), and an optional origin.
factory
Point.fromSphericalCoordinates(dynamic r, dynamic theta, dynamic phi)
Creates a 3D point and sets the coordinates of the point given spherical coordinates r, theta, and phi.
factory
Point.origin([bool is3DPoint = true])
Creates a point at the origin of the coordinate system. If is3DPoint is true, the point will have a z-coordinate of zero. Otherwise, the point will be a 2D point with only x and y coordinates.
factory

Properties

direction → dynamic

Available on Vector, provided by the VectorOperations extension

Returns the direction (or angle) of the vector, in radians.
no setter
elements Iterable
Getter to retrieve an iterable over all elements in the matrix, regardless of their row or column.
no setterinherited
first → dynamic
The first element.
no setterinherited
firstOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The first element of this iterator, or null if the iterable is empty.
no setter
hashCode int
The hash code for this object.
no setteroverride
indexed Iterable<(int, T)>

Available on Iterable<T>, provided by the IterableExtensions extension

Pairs of elements of the indices and elements of this iterable.
no setter
isEmpty bool
Whether this collection has no elements.
no setterinherited
isNotEmpty bool
Whether this collection has at least one element.
no setterinherited
iterator Iterator
Overrides the iterator getter to provide a VectorIterator. This iterator iterates over the elements of the vector.
no setterinherited
last → dynamic
The last element.
no setterinherited
lastOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The last element of this iterable, or null if the iterable is empty.
no setter
length int
Returns the length (number of elements) of the vector.
no setterinherited
magnitude → dynamic

Available on Vector, provided by the VectorOperations extension

Returns the magnitude (or norm) of the vector.
no setter
nonNulls Iterable<T>

Available on Iterable<T?>, provided by the NullableIterableExtensions extension

The non-null elements of this iterable.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
single → dynamic
Checks that this iterable has only one element, and returns that element.
no setterinherited
singleOrNull → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The single element of this iterator, or null.
no setter
wait Future<List<T>>

Available on Iterable<Future<T>>, provided by the FutureIterable extension

Waits for futures in parallel.
no setter
x ↔ dynamic
The x-coordinate of the point.
getter/setter pair
y ↔ dynamic
The y-coordinate of the point.
getter/setter pair
z ↔ dynamic
The z-coordinate of the point. If the point is 2D, this value is null.
getter/setter pair

Methods

abs() Vector

Available on Vector, provided by the VectorOperations extension

Returns a new vector with the absolute values of the original vector's elements.
addMatrix(Matrix matrix) Matrix

Available on Vector, provided by the VectorMatrixOperations extension

Add a vector and a matrix
angle(Vector other) → dynamic
Returns the angle (in radians) between this vector and other.
inherited
angleBetween(Point otherPoint) Angle
Calculates the angle (in radians) between this point and another, considering the line between them as the hypotenuse of a right triangle.
any(bool test(dynamic element)) bool
Checks whether any element of this iterable satisfies test.
inherited
asNameMap() Map<String, T>

Available on Iterable<T>, provided by the EnumByName extension

Creates a map from the names of enum values to the values.
bearingTo(Point point, {bool isXAxis = true}) Angle
Computes the bearing from this point to another point.
byName(String name) → T

Available on Iterable<T>, provided by the EnumByName extension

Finds the enum value in this list with name name.
cast<R>() Iterable<R>
A view of this iterable as an iterable of R instances.
inherited
contains(Object? element) bool
Whether the collection contains an element equal to element.
inherited
cross(Vector other) Vector

Available on Vector, provided by the VectorOperations extension

Calculates the cross product of the vector with another vector.
distance(Vector other, {DistanceType distance = DistanceType.frobenius}) Complex
Sets all elements of this vector to value.
inherited
distanceTo(Point otherPoint) double
Computes the Euclidean distance between this point and another.
distanceToCircle(Point center, double radius) double
Calculates the shortest distance from this point to a circle. If this point is inside the circle, the distance is 0.
distanceToLine(Point linePoint1, Point linePoint2) double
Calculates the shortest distance from this point to a line defined by two points.
distanceToPolyline(List<Point> polyline) double
Calculates the shortest distance from this point to a polyline, which is a list of points forming a broken line.
dot(Vector other) → dynamic

Available on Vector, provided by the VectorOperations extension

Calculates the dot product of the vector with another vector.
elementAt(int index) → dynamic
Returns the indexth element.
inherited
elementAtOrNull(int index) → T?

Available on Iterable<T>, provided by the IterableExtensions extension

The element at position index of this iterable, or null.
every(bool test(dynamic element)) bool
Checks whether every element of this iterable satisfies test.
inherited
exp() Vector

Available on Vector, provided by the VectorOperations extension

Returns a new vector with each element being the exponential function of the corresponding element in the original vector.
expand<T>(Iterable<T> toElements(dynamic element)) Iterable<T>
Expands each element of this Iterable into zero or more elements.
inherited
firstWhere(bool test(dynamic element), {dynamic orElse()?}) → dynamic
The first element that satisfies the given predicate test.
inherited
flip() Vector
Flips elements of the vector.
inherited
fold<T>(T initialValue, T combine(T previousValue, dynamic element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(Iterable other) Iterable
Creates the lazy concatenation of this iterable and other.
inherited
forEach(void action(dynamic element)) → void
Invokes action on each element of this iterable in iteration order.
inherited
getVector(List<String> mapping) Vector
Generates a new Vector (Vector2, Vector3, Vector4) based on the mapping provided.
inherited
groupBy<K>(K keyExtractor(T)) Map<K, List<T>>

Available on Iterable<T>, provided by the GroupingExtension extension

Groups the elements of the iterable by a key extracted using the provided keyExtractor function.
innerProduct(Vector other) → dynamic

Available on Vector, provided by the VectorOperations extension

Computes the inner product of two vectors.
insertBetween<T>(T separator) Iterable<T>

Available on Iterable<E>, provided by the IterableExt extension

Extends Iterable with the ability to intersperse an element of type T between each element.
interpolate(Point point1, Point point2) Point
Interpolates between two points, using this point as the ratio. If z is null for any of the points, the resulting point will be 2-dimensional.
is3DPoint() bool
Checks if this point is a 3D point.
isCollinear(Point a, Point b) bool
Checks if this point is collinear with two other points.
isInsidePolygon(List<Point> polygon, [double tolerance = 1e-10]) bool
Checks if this point is inside a polygon or on its boundary. The polygon is represented by a list of points in counter-clockwise order. A tolerance value is used to handle floating point inaccuracies.
isOnLineSegment(Point pointA, Point pointB, [double tolerance = 1e-10]) bool
Checks if the point is on a line segment defined by two points. A tolerance value is used to handle floating point inaccuracies.
isParallelTo(Vector other) bool

Available on Vector, provided by the VectorOperations extension

Checks if this Vector is parallel to other.
isPerpendicularTo(Vector other) bool

Available on Vector, provided by the VectorOperations extension

Checks if this Vector is perpendicular to other.
isUnit() bool
Returns true if this is a unit vector, i.e., its norm is 1.
inherited
isZero() bool
Returns true if this is a zero vector, i.e., all its elements are zero.
inherited
join([String separator = ""]) String
Converts each element to a String and concatenates the strings.
inherited
lastWhere(bool test(dynamic element), {dynamic orElse()?}) → dynamic
The last element that satisfies the given predicate test.
inherited
map<T>(T toElement(dynamic e)) Iterable<T>
The current elements of this iterable modified by toElement.
inherited
mean() → dynamic

Available on Vector, provided by the VectorOperations extension

Returns the arithmetic mean of the vector.
median() → dynamic

Available on Vector, provided by the VectorOperations extension

Returns the median value of the vector. If the vector has an even number of elements, the median is calculated as the mean of the two central elements.
midpointTo(Point otherPoint) Point
Computes the midpoint between this point and another.
move(dynamic dx, dynamic dy, [dynamic dz]) Point
Moves the point by a given delta along each axis.
norm([Norm normType = Norm.frobenius]) Complex

Available on Vector, provided by the VectorOperations extension

Returns the norm (or length) of this vector.
normalize([Norm normType = Norm.frobenius]) Vector

Available on Vector, provided by the VectorOperations extension

Returns this vector normalized.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
outerProduct(Vector other) Matrix

Available on Vector, provided by the VectorOperations extension

Computes the outer product of two vectors.
polarCoordinates() → (dynamic, Angle)
Returns the polar coordinates (r, theta) of the point, where r is the distance from the origin and theta is the angle in radians.
pop() → dynamic
Removes the last value in the row.
inherited
pow(num exponent) Vector

Available on Vector, provided by the VectorOperations extension

Returns a new vector with each element being raised to the provided exponent.
product() → dynamic

Available on Vector, provided by the VectorOperations extension

Returns the product of all elements in the vector.
projection(Vector other) Vector
Returns the projection of this vector onto other.
inherited
push(num value) → void
Adds a new value at the end of the row.
inherited
reduce(dynamic combine(dynamic value, dynamic element)) → dynamic
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
reflect([Point? origin]) Point
Reflects the point through the given origin.
rescale() Vector

Available on Vector, provided by the VectorOperations extension

Rescales the vector to the range 0-1.
roll(dynamic shift) Vector
Rolls the elements in a 1D list by a certain amount.
inherited
rotate(Angle angle) Point
Rotates the point around the origin (0, 0) by a given angle (in radians).
rotateBy(Angle angle, [Point? origin]) Point
Rotates the point around a given origin by a specific `angle (in radians).
round([int decimalPlaces = 0]) Vector

Available on Vector, provided by the VectorOperations extension

Rounds each element in the vector to the specified number of decimal places.
scale(dynamic scalar) Vector

Available on Vector, provided by the VectorOperations extension

Scales a vector by a given scalar.
scale(dynamic factor) Point
Scales the point by a given factor.
shift() → dynamic
Removes the first value in the row.
inherited
singleWhere(bool test(dynamic element), {dynamic orElse()?}) → dynamic
The single element that satisfies test.
inherited
skip(int count) Iterable
Creates an Iterable that provides all but the first count elements.
inherited
skipWhile(bool test(dynamic value)) Iterable
Creates an Iterable that skips leading elements while test is satisfied.
inherited
slopeTo(Point otherPoint) Complex
Calculates the slope of the line formed by this point and another.
splice(int start, int deleteCount, [List<num> newItems = const []]) → void
Adds/removes elements at an arbitrary position in the row.
inherited
subtractMatrix(Matrix matrix) Matrix

Available on Vector, provided by the VectorMatrixOperations extension

Subtract a matrix from a vector
subVector({List<int>? indices, String range = '', int? start, int? end}) Vector
Extracts a subVector from the given vector using the specified indices or range.
inherited
sum() → dynamic

Available on Vector, provided by the VectorOperations extension

Returns the sum of all elements in the vector.
sum([dynamic selector(E)?]) → dynamic

Available on Iterable<E>, provided by the IterableExt extension

Returns the sum of all elements in this iterable.
swap(int index1, int index2) → void
Swaps two elements in the row.
inherited
take(int count) Iterable
Creates a lazy iterable of the count first elements of this iterable.
inherited
takeWhile(bool test(dynamic value)) Iterable
Creates a lazy iterable of the leading elements satisfying test.
inherited
toCylindrical() List
Converts the Vector from Cartesian to Cylindrical coordinates.
inherited
toDiagonal() Matrix
Returns the leading diagonal matrix from a vector.
inherited
toList({bool growable = true}) List
Creates a List containing the elements of this Iterable.
inherited
toMatrix(int rows, int cols, {bool fillWithZeros = true}) Matrix
Constructs a new Matrix from a vector.
inherited
toPoint() Point
inherited
toPolar() List
Converts the Vector from Cartesian to Polar coordinates.
inherited
toSet() Set
Creates a Set containing the same elements as this iterable.
inherited
toSpherical() List
Converts the Vector from Cartesian to Spherical coordinates.
inherited
toString() String
A custom toString method for better readability.
override
toVector() Vector
Converts this Point to a list of numbers, which can be used to represent it as a vector.
translate(num dx, num dy, [num? dz]) Point
Translates the point by the given amounts dx, dy, and dz.
triangleArea(Point point1, Point point2) Complex
Calculates the area of the triangle formed by this point and two other points.
unShift(num value) → void
Adds a new value at the beginning of the row.
inherited
where(bool test(dynamic element)) Iterable
Creates a new lazy Iterable with all elements that satisfy the predicate test.
inherited
whereType<T>() Iterable<T>
Creates a new lazy Iterable with all elements that have type T.
inherited

Operators

operator *(dynamic scalar) Point
Overrides the multiplication (*) operator.
operator *(dynamic other) Vector

Available on Vector, provided by the VectorOperations extension

operator +(Point other) Point
Overrides the addition (+) operator.
operator +(dynamic other) → dynamic

Available on Vector, provided by the VectorOperations extension

operator -(Point other) Point
Overrides the subtraction (-) operator.
operator -(dynamic other) → dynamic

Available on Vector, provided by the VectorOperations extension

operator /(dynamic scalar) Point
Overrides the division (/) operator.
operator /(dynamic other) Vector

Available on Vector, provided by the VectorOperations extension

operator ==(Object other) bool
Overloads the == (equality) operator.
override
operator [](int index) → dynamic
Fetches the value at the given index of the vector.
inherited
operator []=(int index, dynamic value) → void
Sets the value at the given index of the vector.
inherited
operator unary-() Vector

Available on Vector, provided by the VectorOperations extension

Negates this vector element-wise.