Point2D
Companion object for Point2D, providing convenient factory methods.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Point2D.type
Members list
Value members
Concrete methods
Extensions
Extensions
Multiplies this point by a scalar value, resulting in a new point whose coordinates are the product of the respective coordinates of this point and the scalar.
Multiplies this point by a scalar value, resulting in a new point whose coordinates are the product of the respective coordinates of this point and the scalar.
Value parameters
- scalar
-
scalar value to multiply the point by.
Attributes
- Returns
-
a new Point2D representing the scaled point.
Adds two points together, resulting in a new point whose coordinates are the sum of the respective coordinates of the two points.
Adds two points together, resulting in a new point whose coordinates are the sum of the respective coordinates of the two points.
Value parameters
- other
-
the other point to add.
Attributes
- Returns
-
a new Point2D representing the sum of this point and
other
.
Subtracts another point from this point, resulting in a new point whose coordinates are the difference of the respective coordinates of the two points.
Subtracts another point from this point, resulting in a new point whose coordinates are the difference of the respective coordinates of the two points.
Value parameters
- other
-
the other point to subtract.
Attributes
- Returns
-
a new Point2D representing the difference of this point and
other
.
Computes the Euclidean distance between this point and another point.
Computes the Euclidean distance between this point and another point.
The Euclidean distance is calculated as:
sqrt((x2 - x1)^2 + (y2 - y1)^2)
Value parameters
- other
-
the other point to which the distance is measured.
Attributes
- Returns
-
the Euclidean distance between this point and
other
.
Calculates the dot product of this point with another point.
Calculates the dot product of this point with another point.
Value parameters
- other
-
the other point to compute the dot product with.
Attributes
- Returns
-
the dot product as a
Double
, which is the sum of the products of the corresponding coordinates.
Calculates the magnitude (length) of this point vector.
Calculates the magnitude (length) of this point vector.
Attributes
- Returns
-
the magnitude as a
Double
, which is the square root of the sum of the squares of the coordinates.
Normalizes this point to a unit vector.
Normalizes this point to a unit vector.
Attributes
- Returns
-
a new Point2D representing the normalized point.
The x-coordinate of this point.
The x-coordinate of this point.
Attributes
The y-coordinate of this point.
The y-coordinate of this point.