Package renderer.models_L
Class SquareGrid
- java.lang.Object
-
- renderer.scene.Model
-
- renderer.models_L.SquareGrid
-
- All Implemented Interfaces:
MeshMaker
public class SquareGrid extends Model implements MeshMaker
Create a wireframe model of a square in the xy-plane centered at the origin.
-
-
Field Summary
Fields Modifier and Type Field Description int
k
int
n
double
r
-
Fields inherited from class renderer.scene.Model
colorList, name, primitiveList, vertexList, visible
-
-
Constructor Summary
Constructors Constructor Description SquareGrid()
Create a square in the xy-plane with corners(±1, ±1, 0)
.SquareGrid(double r)
Create a square in the xy-plane with corners(±r, ±r, 0)
.SquareGrid(double r, int n)
Create a square in the xy-plane with corners(±r, ±r, 0)
and withn
grid lines parallel to each of the x and y axes.SquareGrid(double r, int n, int k)
Create a square in the xy-plane with corners(±r, ±r, 0)
and withn
grid lines parallel to the x-axis and withk
grid lines parallel to the y-axis.SquareGrid(int n)
Create a square in the xy-plane with corners(±1, ±1, 0)
and withn
grid lines parallel to each of the x and y axes.SquareGrid(int n, int k)
Create a square in the xy-plane with corners(±1, ±1, 0)
and withn
grid lines parallel to the x-axis and withk
grid lines parallel to the y-axis.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getHorzCount()
int
getVertCount()
SquareGrid
remake(int n, int k)
Build an instance of theModel
with new values for the number of lines of latitude and longitude while keeping all the other model parameters the same.-
Methods inherited from class renderer.scene.Model
addColor, addPrimitive, addVertex, getPrimitive, toString
-
-
-
-
Constructor Detail
-
SquareGrid
public SquareGrid()
Create a square in the xy-plane with corners(±1, ±1, 0)
.
-
SquareGrid
public SquareGrid(int n)
Create a square in the xy-plane with corners(±1, ±1, 0)
and withn
grid lines parallel to each of the x and y axes.- Parameters:
n
- number of grid lines parallel to the axes- Throws:
IllegalArgumentException
- ifn
is less than 0
-
SquareGrid
public SquareGrid(int n, int k)
Create a square in the xy-plane with corners(±1, ±1, 0)
and withn
grid lines parallel to the x-axis and withk
grid lines parallel to the y-axis.If there are
n
grid lines parallel to the x-axis, then each grid line parallel to the y-axis will haven+1
line segments. If there arek
grid lines parallel to the y-axis, then each grid line parallel to the x-axis will havek+1
line segments.- Parameters:
n
- number of grid lines parallel to the x-axisk
- number of grid lines parallel to the y-axis- Throws:
IllegalArgumentException
- ifn
is less than 0IllegalArgumentException
- ifk
is less than 0
-
SquareGrid
public SquareGrid(double r)
Create a square in the xy-plane with corners(±r, ±r, 0)
.- Parameters:
r
- determines the corners of the square- Throws:
IllegalArgumentException
- ifr
is less than or equal to 0
-
SquareGrid
public SquareGrid(double r, int n)
Create a square in the xy-plane with corners(±r, ±r, 0)
and withn
grid lines parallel to each of the x and y axes.- Parameters:
r
- determines the corners of the squaren
- number of grid lines parallel to the axes- Throws:
IllegalArgumentException
- ifn
is less than 0IllegalArgumentException
- ifr
is less than or equal to 0
-
SquareGrid
public SquareGrid(double r, int n, int k)
Create a square in the xy-plane with corners(±r, ±r, 0)
and withn
grid lines parallel to the x-axis and withk
grid lines parallel to the y-axis.If there are
n
grid lines parallel to the x-axis, then each grid line parallel to the y-axis will haven+1
line segments. If there arek
grid lines parallel to the y-axis, then each grid line parallel to the x-axis will havek+1
line segments.- Parameters:
r
- determines the corners of the squaren
- number of grid lines parallel to the x-axisk
- number of grid lines parallel to the y-axis- Throws:
IllegalArgumentException
- ifn
is less than 0IllegalArgumentException
- ifk
is less than 0IllegalArgumentException
- ifr
is less than or equal to 0
-
-
Method Detail
-
getHorzCount
public int getHorzCount()
- Specified by:
getHorzCount
in interfaceMeshMaker
- Returns:
- the number of lines of latitude that the
Model
contains
-
getVertCount
public int getVertCount()
- Specified by:
getVertCount
in interfaceMeshMaker
- Returns:
- the number of lines of longitude that the
Model
contains
-
remake
public SquareGrid remake(int n, int k)
Description copied from interface:MeshMaker
Build an instance of theModel
with new values for the number of lines of latitude and longitude while keeping all the other model parameters the same.
-
-