Point2D

io.github.srs.model.entity.Point2D$package.Point2D
object Point2D

Companion object for Point2D, providing convenient factory methods.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Point2D.type

Members list

Value members

Concrete methods

def apply(x: Double, y: Double): Point2D

Creates a new Point2D instance given x and y coordinates.

Creates a new Point2D instance given x and y coordinates.

Value parameters

x

the x-coordinate of the point.

y

the y-coordinate of the point.

Attributes

Returns

a new Point2D representing the given coordinates.

Extensions

Extensions

extension (p: Point2D)
infix def *(scalar: Double): Point2D

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.

infix def +(other: Point2D): Point2D

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.

infix def -(other: Point2D): Point2D

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.

def distanceTo(other: Point2D): Double

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.

infix def dot(other: Point2D): Double

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.

def magnitude: Double

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.

def x: Double

The x-coordinate of this point.

The x-coordinate of this point.

Attributes

def y: Double

The y-coordinate of this point.

The y-coordinate of this point.

Attributes