Package by.andd3dfx.math.matrix
Class MatrixXY
java.lang.Object
by.andd3dfx.math.matrix.Matrix2D
by.andd3dfx.math.matrix.MatrixXY
A specialized matrix for storing pairs of (x,y) coordinates.
This class extends Matrix2D to provide a convenient interface for working
with coordinate pairs, where the first row stores x-coordinates and the
second row stores y-coordinates. The matrix has dimensions 2×N, where N
is the number of coordinate pairs.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
setX
(int i, double value) Sets the x-coordinate at the specified index.void
setY
(int i, double value) Sets the y-coordinate at the specified index.double
x
(int i) Returns the x-coordinate at the specified index.double
y
(int i) Returns the y-coordinate at the specified index.
-
Constructor Details
-
MatrixXY
public MatrixXY(int n) Creates a new matrix for storing N coordinate pairs.- Parameters:
n
- number of coordinate pairs (must be positive)- Throws:
IllegalArgumentException
- if n <= 0
-
-
Method Details
-
setX
public void setX(int i, double value) Sets the x-coordinate at the specified index.- Parameters:
i
- index of the coordinate pair (0 <= i < n)value
- x-coordinate value- Throws:
IllegalArgumentException
- if i < 0 or i >= n
-
x
public double x(int i) Returns the x-coordinate at the specified index.- Parameters:
i
- index of the coordinate pair (0 <= i < n)- Returns:
- x-coordinate value
- Throws:
IllegalArgumentException
- if i < 0 or i >= n
-
setY
public void setY(int i, double value) Sets the y-coordinate at the specified index.- Parameters:
i
- index of the coordinate pair (0 <= i < n)value
- y-coordinate value- Throws:
IllegalArgumentException
- if i < 0 or i >= n
-
y
public double y(int i) Returns the y-coordinate at the specified index.- Parameters:
i
- index of the coordinate pair (0 <= i < n)- Returns:
- y-coordinate value
- Throws:
IllegalArgumentException
- if i < 0 or i >= n
-