public class Vertex extends Object
Vertex
object has three doubles which represent the
coordinates of a point in 3-dimensional space.
When a Vertex
object is created in a client program,
before the Vertex
object moves down the graphics rendering
pipeline, the coordinates in the Vertex
will be in
"camera coordinates".
As a Vertex
object moves down the graphics rendering
pipeline, the coordinates in the Vertex
will be transformed
from one coordinate system to another.
A Vertex
object also has a Color
(or "shade"). The
color of a LineSegment
is interpolated from the colors at
its two endpoints.
Modifier and Type | Field and Description |
---|---|
float |
b |
float |
g |
float |
r |
double |
x |
double |
y |
double |
z |
Constructor and Description |
---|
Vertex()
Construct a default
Vertex . |
Vertex(double x,
double y,
double z)
Construct a new
Vertex using the given
x , y , and z coordinates. |
Vertex(double x,
double y,
double z,
Color c)
Construct a new
Vertex with the given coordinates
and the given Color . |
Vertex(Vertex v)
Construct a new
Vertex that is a copy of another Vertex . |
Modifier and Type | Method and Description |
---|---|
Color |
getColor()
Get the
Color of this Vertex . |
void |
set(double x,
double y,
double z)
Set the coordinates of this
Vertex . |
void |
setColor(Color c)
|
void |
setColor(float r,
float g,
float b)
Set the
Color of this Vertex
using floats between 0 and 1. |
void |
setColor(int r,
int g,
int b)
Set the
Color of this Vertex
using ints between 0 and 255. |
void |
setColor(Vertex v)
|
void |
setColorRandom()
Set the
Color of this Vertex to a random color. |
String |
toString()
For debugging.
|
public float b
public float g
public float r
public double x
public double y
public double z
public Vertex()
Vertex
.public Vertex(double x, double y, double z)
Vertex
using the given
x
, y
, and z
coordinates.x
- x-coordinate of the new Vertex
y
- y-coordinate of the new Vertex
z
- z-coordinate of the new Vertex
public Vertex(double x, double y, double z, Color c)
Vertex
with the given coordinates
and the given Color
.x
- x-coordinate of the new Vertex
y
- y-coordinate of the new Vertex
z
- z-coordinate of the new Vertex
c
- Color
of the new Vertex
public Color getColor()
Color
of this Vertex
.Color
of this Vertex
objectpublic void set(double x, double y, double z)
Vertex
.x
- new x-coordinate for this Vertex
y
- new y-coordinate for this Vertex
z
- new z-coordinate for this Vertex
public void setColor(float r, float g, float b)
Color
of this Vertex
using floats between 0 and 1.r
- red color value for this Vertex
as a float between 0 and 1g
- green color value for this Vertex
as a float between 0 and 1b
- blue color value for this Vertex
as a float between 0 and 1public void setColor(int r, int g, int b)
Color
of this Vertex
using ints between 0 and 255.r
- red color value for this Vertex
as an integer between 0 and 255g
- green color value for this Vertex
as an integer between 0 and 255b
- blue color value for this Vertex
as an integer between 0 and 255public void setColorRandom()
Color
of this Vertex
to a random color.