public class Vertex extends java.lang.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,
java.awt.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 |
---|---|
java.awt.Color |
getColor()
Get the
Color of this Vertex . |
void |
set(double x,
double y,
double z)
Set the coordinates of this
Vertex . |
void |
setColor(java.awt.Color c)
Set the
Color of this Vertex
using a Color object. |
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)
Set the
Color of this Vertex
using the colors from another Vertex . |
void |
setColorRandom()
Set the
Color of this Vertex to a random color. |
java.lang.String |
toString()
For debugging.
|
java.lang.String |
toString(int precision)
For debugging.
|
java.lang.String |
toString(int precision,
int iWidth)
For debugging.
|
java.lang.String |
toStringColor()
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, java.awt.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 java.awt.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(java.awt.Color c)
Color
of this Vertex
using a Color
object.c
- Color
for this Vertex
objectpublic 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 setColor(Vertex v)
Color
of this Vertex
using the colors from another Vertex
.v
- Vertex
object to get color values frompublic void setColorRandom()
Color
of this Vertex
to a random color.public java.lang.String toString()
toString
in class java.lang.Object
String
representation of this Vertex
objectpublic java.lang.String toString(int precision)
Allow the precision of the formatted output to be specified.
precision
- precision value for the format stringString
representation of this Vertex
objectpublic java.lang.String toString(int precision, int iWidth)
Allow the precision and width of the formatted output to be specified. By width, we mean the width of the integer part of each number.
precision
- precision value for the format stringiWidth
- width of the integer part of the format stringString
representation of this Vertex
objectpublic java.lang.String toStringColor()
String
representation of the color information in this Vertex