|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.gwoptics.graphics.Renderable org.gwoptics.graphics.graph3D.SurfaceGraph3D
public final class SurfaceGraph3D
This class incorporates the Axis3D and SurfaceTrace3D objects to construct a 3D Cartesian surface graph. It is possible to draw several surface traces, but care must be taken not to incorporate to many points if the graph is to be rendered with a moving camera, otherwise slower system will struggle to render the graph.
Once the graph is created, it is possible to add traces using the addSurfaceTrace() function. You must specify a callback for the trace which defines the equation it represents. The callback must implement the IGraph3DCallback interface, which allows it to work with the SurfaceTrace3D class by providing a function to compute the values of each point on the surface. It is also possible to specify a colourmap to colour the trace. Several presets can be found in org.gwoptics.graphics.colourmap.presets, or unique ones can be created using the RGBColourmap object. Once the trace is added it must be plotted everytime it is changed using plotSurfaceTrace() otherwise changes will not be seen.
The graphs position denotes the point where all 3 axes meet, the x,y and z axes then all extend in the positive direction by the length values supplied. If in the constructor setAxisCrossAtZero is true, position denotes the location of the minimum point of the z-axis. Axis x and y will then alter themselves automatically to get as close to zero on the z-axis as possible. Due to screen space defining the y axis as 'down' the screen from the top corner, it is recommended that PApplet.scale(1,-1,1) is applied before drawing the graph or a suitable rotation. Or use the Camera3D class which defines the upwards direction to be -y automatically.
Important Note: Due to notation the x and y directions should relate to the grid plane the the height in the z direction. Though due to the way screen space works y is the up direction. This must be taken into account throughout this class.
History
Version 0.3.6 Added functionality to auto-range Z-Axis for a given surface.
Can now alter colour of tick and fonts of axis
Version 0.3.0 Altered to ensure labels were correctly aligned and that the
graph was right-handed.
Version 0.2.4 sees a breaking change of notation relating z as the up
direction, see important note above for more implications of this change.
Also changed class to final, so it cant be extended.
Version 0.2.2 sees the introduction of traces, before only one surface was
plotted. This is not backwards compatiable.
//Example Code for simple sin graph.
g3d = new SurfaceGraph3D(this, 500, 100,500);
g3d.setXAxisMin(-2);
g3d.setXAxisMax(2);
g3d.setYAxisMin(-2);
g3d.setYAxisMax(2);
g3d.setZAxisMin(-1);
g3d.setZAxisMax(1);
//Plot sin graph using preset hot colourmap
g3d.addSurfaceTrace(new IGraph3DCallback(){
public float computePoint(float X, float Y) {
return Math.sin(X) * Math.sin(Y);
}}, 100, 100, new HotColourmap(true));
//Once trace is added it must be plotted.
g3d.plotSurfaceTrace(0);
Axis3D
,
SurfaceTrace3D
,
RGBColourmap
,
org.gwoptics.graphics.colourmap.presets
,
IGraph3DCallback
Field Summary |
---|
Fields inherited from class org.gwoptics.graphics.Renderable |
---|
position |
Constructor Summary | |
---|---|
SurfaceGraph3D(processing.core.PApplet p,
float xLength,
float yLength,
float zLength)
All that needs to be specified to generate a graph is its dimensions. |
|
SurfaceGraph3D(processing.core.PApplet p,
float xLength,
float yLength,
float zLength,
boolean setAxisCrossAtZero)
All that needs to be specified to generate a graph is its dimensions. |
Method Summary | |
---|---|
void |
addSurfaceTrace(IGraph3DCallback cb,
int XRes,
int YRes,
IColourmap map)
Adds a surface trace to the graph. |
void |
draw()
Draws each segment of the graph, all the traces and axes. |
int |
getTraceCount()
|
float |
getZAxisMax()
|
void |
plotSurfaceTrace(int index)
This function starts the surface calling the callback object to generate the surface |
void |
removeSurfaceTrace(int index)
Removes trace from the graph. |
void |
setAutoRanging(int surfaceIndex)
Use this to set a surface to automatically set the min and max values of the Z-axis to match the computed values, resulting in no clipping of surface points. |
void |
setAxisColour(GWColour c)
|
void |
setAxisColour(int R,
int G,
int B)
|
void |
setBillboarding(boolean value)
|
void |
setDrawAxisLabel(boolean value)
|
void |
setDrawLines(boolean value)
|
void |
setDrawTickLabels(boolean value)
|
void |
setDrawTicks(boolean value)
|
void |
setFontColour(GWColour c)
|
void |
setFontColour(int R,
int G,
int B)
|
void |
setTraceFill(int index,
GWColour c)
Fills the trace with a solid colour if no colourmap is specified |
void |
setTraceStroke(int index,
GWColour c)
sets the colour of the wireframe of a trace if no colourmap is specified |
void |
setXAxisLabel(java.lang.String s)
|
void |
setXAxisLabelAccuracy(int l)
|
void |
setXAxisLabelType(ValueType l)
|
void |
setXAxisMajorTicks(int n)
|
void |
setXAxisMax(float l)
|
void |
setXAxisMin(float l)
|
void |
setXAxisMinorTicks(int n)
|
void |
setYAxisLabel(java.lang.String s)
|
void |
setYAxisLabelAccuracy(int l)
|
void |
setYAxisLabelType(ValueType l)
|
void |
setYAxisMajorTicks(int n)
|
void |
setYAxisMax(float l)
|
void |
setYAxisMin(float l)
|
void |
setYAxisMinorTicks(int n)
|
void |
setZAxisLabel(java.lang.String s)
|
void |
setZAxisLabelAccuracy(int l)
|
void |
setZAxisLabelType(ValueType l)
|
void |
setZAxisMajorTicks(int n)
|
void |
setZAxisMax(float l)
|
void |
setZAxisMin(float l)
|
void |
setZAxisMinorTicks(int n)
|
Methods inherited from class org.gwoptics.graphics.Renderable |
---|
setParent |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SurfaceGraph3D(processing.core.PApplet p, float xLength, float yLength, float zLength)
p
- PApplet that will render this objectxLength
- Length of the X-AxisyLength
- Length of the Y-AxiszLength
- Length of the Z-Axispublic SurfaceGraph3D(processing.core.PApplet p, float xLength, float yLength, float zLength, boolean setAxisCrossAtZero)
p
- PApplet that will render this objectxLength
- Length of the X-AxisyLength
- Length of the Y-AxiszLength
- Length of the Z-AxissetAxisCrossAtZero
- boolean stating whether to make axes cross at zeroMethod Detail |
---|
public float getZAxisMax()
public void setXAxisMin(float l)
public void setYAxisMin(float l)
public void setZAxisMin(float l)
public void setXAxisMax(float l)
public void setYAxisMax(float l)
public void setZAxisMax(float l)
public void setXAxisLabel(java.lang.String s)
public void setYAxisLabel(java.lang.String s)
public void setZAxisLabel(java.lang.String s)
public void setXAxisLabelAccuracy(int l)
public void setYAxisLabelAccuracy(int l)
public void setZAxisLabelAccuracy(int l)
public void setXAxisLabelType(ValueType l)
public void setYAxisLabelType(ValueType l)
public void setZAxisLabelType(ValueType l)
public void setXAxisMajorTicks(int n)
public void setXAxisMinorTicks(int n)
public void setYAxisMajorTicks(int n)
public void setYAxisMinorTicks(int n)
public void setZAxisMajorTicks(int n)
public void setZAxisMinorTicks(int n)
public void setBillboarding(boolean value)
public void setDrawLines(boolean value)
public void setDrawTickLabels(boolean value)
public void setDrawTicks(boolean value)
public void setDrawAxisLabel(boolean value)
public void setAxisColour(int R, int G, int B)
public void setAxisColour(GWColour c)
public void setFontColour(int R, int G, int B)
public void setFontColour(GWColour c)
public void setAutoRanging(int surfaceIndex)
surfaceIndex
- The index of the surface to autorange the z axispublic int getTraceCount()
public void addSurfaceTrace(IGraph3DCallback cb, int XRes, int YRes, IColourmap map)
cb
- IGraph3DCallback that represents the equation of the traceXRes
- Number of squares along x side of grid, the higher the more
detailed the graphYRes
- Number of squares along z side of grid, the higher the more
detailed the graphmap
- Null for wireframe rendering. Otherwise specifies how to
colour the surface.public void removeSurfaceTrace(int index)
index
- Index of trace to removepublic void plotSurfaceTrace(int index)
index
- index of trace the generatepublic void setTraceStroke(int index, GWColour c)
index
- index of tracec
- colour of wireframepublic void setTraceFill(int index, GWColour c)
index
- index of tracec
- colour to fill surfacepublic void draw()
draw
in interface IRenderable
draw
in class Renderable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |