Shapes 3D
3.0
|
Public Member Functions | |
BCurve2D (float[] x, float[] y, int nbrSlices) | |
BCurve2D (float[][] points, int nbrSlices) | |
BCurve2D (List< PVector > points, int nbrSlices) | |
BCurve2D (PVector[] points, int nbrSlices) | |
void | insertCtrlPoints (float[][] pts, int nbrPts, int pos) |
void | insertCtrlPoints (float[] ptsX, float ptsY[], int nbrPts, int pos) |
void | insertCtrlPoints (PVector[] points, int nbrPts, int pos) |
void | insertCtrlPoint (PVector point, int pos) |
void | insertCtrlPoint (float x, float y, int pos) |
boolean | removeCtrlPoints (int first, int last) |
boolean | removeCtrlPoint (int point) |
void | updateCtrlPoint (PVector point, int pos) |
void | updateCtrlPoint (float x, float y, int pos) |
PVector | getCtrlPoint (int pos) |
void | listCtrlPoints () |
int | getNbrCtrlPoints () |
PVector[] | getCtrlPointArray () |
PVector | point (float t) |
PVector | tangent (float t) |
PVector | orthogonal (float t) |
float | length (float t0, float t1, int steps) |
float | length (int steps) |
Public Member Functions inherited from shapes3d.path.AbstractPath | |
int | nbrSlices () |
PVector | tangent (float t) |
PVector | orthogonal (float t) |
boolean | isOpenPath () |
Additional Inherited Members | |
Public Attributes inherited from shapes3d.path.AbstractPath | |
PathOrthogonal | orthoCalculator = null |
Public Attributes inherited from shapes3d.utils.SConstants | |
int | WIRE = 0x00000011 |
int | SOLID = 0x00000012 |
int | TEXTURE = 0x00000014 |
int | DRAWALL = WIRE | SOLID | TEXTURE |
int | WHITE = 0xFFFFFFFF |
int | BLACK = 0xFF000000 |
int | GREY = 0xFFC0C0C0 |
int | RED = 0xFFFF0000 |
int | GREEN = 0xFF00FF00 |
int | BLUE = 0xFF0000FF |
int | YELLOW = 0xFFFFFF00 |
int | PURPLE = 0xFFFF00FF |
int | CYAN = 0xFF00FFFF |
int | ORANGE = 0xFFFFC000 |
int | CW = 1 |
int | CCW = 2 |
int | ALL = 0b11111111 |
int | BOTTOM = 0b00000001 |
int | TOP = 0b00000010 |
int | FRONT = 0b00000100 |
int | BACK = 0b00001000 |
int | LEFT = 0b00010000 |
int | RIGHT = 0b00100000 |
int | BODY = 0b00000001 |
int | END0 = 0b00000010 |
int | END1 = 0b00000100 |
float | ONE_DEG_T = (float) (Math.PI / 180.0) |
PathOrthogonal | ORTHO_X = new PathOrthogonal.PathNormalX() |
PathOrthogonal | ORTHO_Y = new PathOrthogonal.PathNormalY() |
PathOrthogonal | ORTHO_Z = new PathOrthogonal.PathNormalZ() |
PathOrthogonal | ORTHO_A = new PathOrthogonal.PathNormalAMC() |
TransformUV | ROT_0 = TransformUV.ROT0 |
TransformUV | ROT_90 = TransformUV.ROT90 |
TransformUV | ROT_180 = TransformUV.ROT180 |
TransformUV | ROT_270 = TransformUV.ROT270 |
TransformUV | FLIP_H = TransformUV.FLIPH |
TransformUV | FLIP_V = TransformUV.FLIPV |
Rotation | ROTATION_ZERO = new Rotation() |
int | T_BOX = 0x1001 |
int | T_DOME = 0x1002 |
int | T_CONE = 0x1003 |
int | T_ELLIPSOID = 0x1004 |
int | T_EXTRUSION = 0x1005 |
int | T_LATHESTOCK = 0x1006 |
int | T_MD2 = 0x1007 |
int | T_SKYBOX = 0x1008 |
int | T_SKYDOME = 0x1009 |
int | T_TERRAIN = 0x100A |
int | T_TUBE = 0x100B |
int | C_LATHESURFACE = 0x2001 |
int | C_OVAL = 0x2002 |
int | C_POLYGON = 0x2003 |
int | P_BCURVE2D = 0x3001 |
int | P_BCURVE3D = 0x3002 |
int | P_BSPLINE2D = 0x3003 |
int | P_BSPLINE3D = 0x3004 |
int | P_LINEAR = 0x3005 |
int | P_LISSAJOUS = 0x3006 |
int | P_RING = 0x3007 |
int | P_SPIRAL = 0x3008 |
Protected Member Functions inherited from shapes3d.path.AbstractPath | |
AbstractPath () | |
AbstractPath (int nbrSlices) | |
Protected Attributes inherited from shapes3d.path.AbstractPath | |
final int | DEFAULT_NBR_SLICES = 100 |
final int | nbrSlices |
boolean | pathIsOpen = true |
This class is used to represent a single Bezier curve of degree ≥ 2 in 2D space.
Note the degree of a Bezier curve equals the number of control points.
Its primary purpose is to act as a convenience class to maintain a collection bezier controls points in 2 dimensions.
In this library the Bezier2D object is used by the BezierShape class to create a 3D shape by rotating it about the Y axis [0,1,0].
Degree Shape
2 straight line
3 quadratic bezier
4 cubic bezier
and so on
Based on source code found on the Internet and modified by the author to work directly with Processing. The URL for the original code has been lost).
shapes3d.path.BCurve2D.BCurve2D | ( | float[] | x, |
float[] | y, | ||
int | nbrSlices | ||
) |
Creates a Bezier object using two arrays for the x and y positions for each control points.
If the arrays passed to this constructor differ in length the extra in the longer array are ignored.
x | array of the x values of the control point positions |
y | array of the y values of the control point positions |
nbrSlices | the number of slices along the curve's length Creates a Bezier object using an array of control point positions. The bezier curve will use all of the points in the array. |
points | 2D array[point no.][x/y] of control point positions |
nbrSlices | the number of slices along the curve's length Create a Bezier curve that passes through the specified positions |
points | array of PVectors defining the spline. |
nbrSlices | the number of slices along the length of the path Creates a Bezier object using an array of control point positions. The bezier curve will use all of the points in the array. |
points | array of vertices defining the hull for this Bezier curve |
nbrSlices | the number os slices along the curve's length Creates a Bezier object using two arrays for the x and y positions for each control points. If the arrays passed to this constructor differ in length the extra in the longer array are ignored. |
x | array of the x values of the control point positions |
y | array of the y values of the control point positions |
nbrSlices | the number of slices along the curve's length |
shapes3d.path.BCurve2D.BCurve2D | ( | float | points[][], |
int | nbrSlices | ||
) |
Creates a Bezier object using an array of control point positions. The bezier curve will use all of the points in the array.
points | 2D array[point no.][x/y] of control point positions |
nbrSlices | the number of slices along the curve's length |
shapes3d.path.BCurve2D.BCurve2D | ( | List< PVector > | points, |
int | nbrSlices | ||
) |
Create a Bezier curve that passes through the specified positions
points | array of PVectors defining the spline. |
nbrSlices | the number of slices along the length of the path |
shapes3d.path.BCurve2D.BCurve2D | ( | PVector[] | points, |
int | nbrSlices | ||
) |
Creates a Bezier object using an array of control point positions. The bezier curve will use all of the points in the array.
points | array of vertices defining the hull for this Bezier curve |
nbrSlices | the number os slices along the curve's length |
PVector shapes3d.path.BCurve2D.getCtrlPoint | ( | int | pos | ) |
Get a control point
pos | constrained to array bounds |
PVector [] shapes3d.path.BCurve2D.getCtrlPointArray | ( | ) |
Get the bezier control points
int shapes3d.path.BCurve2D.getNbrCtrlPoints | ( | ) |
Get the number of control points used to form the curve.
void shapes3d.path.BCurve2D.insertCtrlPoint | ( | PVector | point, |
int | pos | ||
) |
Insert a single points into the bezier curve.
point | a single point |
pos | the position to insert (≤0 before first point; ≥ degree after last point) |
void shapes3d.path.BCurve2D.insertCtrlPoint | ( | float | x, |
float | y, | ||
int | pos | ||
) |
Insert a single points into the bezier curve.
x | x coordinate of point |
y | y coordinate of point |
pos | the position to insert (≤0 before first point; ≥ degree after last point) |
void shapes3d.path.BCurve2D.insertCtrlPoints | ( | float | pts[][], |
int | nbrPts, | ||
int | pos | ||
) |
Insert a number of points into the bezier curve.
pts | a 2D array of point i.e. [x][y] |
nbrPts | the number of points to insert |
pos | the position to insert (≤0 before first point; ≥ degree after last point) |
void shapes3d.path.BCurve2D.insertCtrlPoints | ( | float[] | ptsX, |
float | ptsY[], | ||
int | nbrPts, | ||
int | pos | ||
) |
Insert a number of points into the bezier curve.
ptsX | array of point x values |
ptsY | array of point y values |
nbrPts | the number of points to insert |
pos | the position to insert (≤0 before first point; ≥ degree after last point) |
void shapes3d.path.BCurve2D.insertCtrlPoints | ( | PVector[] | points, |
int | nbrPts, | ||
int | pos | ||
) |
Insert a number of points into the bezier curve.
Although using PVector only the x,y values of the vector are used.
points | an array of PVector's |
nbrPts | the number of points to insert |
pos | the position to insert (≤0 before first point; ≥ degree after last point) |
float shapes3d.path.BCurve2D.length | ( | float | t0, |
float | t1, | ||
int | steps | ||
) |
Calculate the path length of a section of Bezier curve.
There is no formula for the exact length of a Bezier curve so any method will always be approximate.
This method will always 'underestimate' the actual path length. It works by subdividing the Bezier curve into a number of straight line segments and summing their lengths.
The number of subdivisions can be increased to the accuracy of the result but at the cost of additional computation.
You may want to experiment but 100+ subdivisions normally give quite good results.
t0 | start ( ≥0.0 and <t1 ) |
t1 | end ( >t0 and ≤1.0 ) |
steps | number of subdivisions |
float shapes3d.path.BCurve2D.length | ( | int | steps | ) |
Calculate the path length of the Bezier curve.
There is no formula for the exact length of a Bezier curve so any method will always be approximate.
This method will always 'underestimate' the actual path length. It works by subdividing the Bezier curve into a number of straight line segments and summing their lengths.
The number of subdivisions can be increased to the accuracy of the result but at the cost of additional computation.
You may want to experiment but 100+ subdivisions normally give quite good results.
steps | number of subdivisions |
void shapes3d.path.BCurve2D.listCtrlPoints | ( | ) |
List the points to console, used for debugging
PVector shapes3d.path.BCurve2D.orthogonal | ( | float | t | ) |
Calculate the normal vector for a point on the bezier curve
t | parametric value ≥0.0 and ≤1.0 |
Implements shapes3d.path.Path.
|
virtual |
Calculate the point for a given parametric point 't' on the bezier curve.
t | parametric value ≥0.0 and ≤1.0 |
Implements shapes3d.path.AbstractPath.
boolean shapes3d.path.BCurve2D.removeCtrlPoint | ( | int | point | ) |
Removes a single control point
Silently fails if point is outside array bounds or if it would leave less than 2 control points.
point | control point to remove |
boolean shapes3d.path.BCurve2D.removeCtrlPoints | ( | int | first, |
int | last | ||
) |
Remove control points from first to last inclusive.
Silently fails if first or last are outside array bounds or last < first or if it means the number of points left would be < 2
first | the first point to be removed |
last | the last point to be removed |
PVector shapes3d.path.BCurve2D.tangent | ( | float | t | ) |
Calculate the tangent vector for a point on the bezier curve
t | parametric value ≥0.0 and ≤1.0 |
Implements shapes3d.path.Path.
void shapes3d.path.BCurve2D.updateCtrlPoint | ( | PVector | point, |
int | pos | ||
) |
Change the value stored in a point.
point | the control oint to change |
pos | constrained to array bounds |
void shapes3d.path.BCurve2D.updateCtrlPoint | ( | float | x, |
float | y, | ||
int | pos | ||
) |
Change the value stored in a point.
x | the new x value |
y | the new y value |
pos | constrained to array bounds |