<< Chapter < Page Chapter >> Page >

As opposed to the curve() , in the bezier() function call the two control points specified by the four middle parameters are not points touchedby the curve. They only serve to define the shape of the approximating Bézier curve , which has the following interesting properties:

  • it is entirely contained in the convex hull defined by the extremal points and the control points;
  • transformations of translation, rotation, or scaling, appied to the extremal and controlpoints determine a similar transformation of the curve.
As we can see by running the code stroke(255, 0, 0); line(93, 40, 10, 10);line(90, 90, 15, 80); stroke(0, 0, 0);noFill(); bezier(93, 40, 10, 10, 90, 90, 15, 80); the control points lay on the tangent passing by the extremal points. In order to have an arbitrary number ofcontrol points one must use the bezierVertex() to specify each point within a block delimited by beginShape() and endShape() . In this way, an arbitrarily involute curve can be traced in the 3D space. In 2D, thefunction bezierVertex() has six parameters that correspond to the coordinates of two control points and oneanchor point. The first invocation of bezierVertex() has to be preceded by a call to vertex() which fixes the first anchor point of the curve.

There are other methods that allow to read the coordinates or the slope of the tangent to an arbitrary point of aBézier or spline curve. Such point can be specified by a parameter t that can go from 0 (first extreme) to 1 (second extreme). It is also possible to set the precision of approximating orinterpolating curves in 3D. For details see the Processing reference manual .

The Processing sketch in table shows the difference between the spline interpolating curve and the Bézier curve.

See the term Bézier curve in Wikipedia.
applet that compares the Bézier curve (red) and theinterpolating spline (black) void setup() { c1x = 120;c1y = 110; c2x = 50;c2y = 70; background(200);stroke(0,0,0); size(200, 200);} int D1, D2;int X, Y; int c1x, c1y, c2x, c2y;void draw() { if (mousePressed == true) {X = mouseX; Y = mouseY; // selection of the point that is modifiedD1 = (X - c1x)*(X - c1x) + (Y - c1y)*(Y - c1y); D2 = (X - c2x)*(X - c2x) + (Y - c2y)*(Y - c2y);if (D1<D2) { c1x = X; c1y = Y;} else {c2x = X; c2y = Y; }} background(200);stroke(0,0,0); strokeWeight(1);noFill();beginShape(); curveVertex(10, 10);curveVertex(10, 10); curveVertex(c2x, c2y);curveVertex(c1x, c1y); curveVertex(190, 190);curveVertex(190, 190); endShape();stroke(255,30,0);bezier(10,10,c2x,c2y,c1x,c1y,190,190); strokeWeight(4);point(c1x,c1y); point(c2x,c2y);}

2d

Objects in two or three dimensions take a color that can be determined by the illumination, asexplained in [link] , or established by the method fill() , which also gives the possibility to set the degree of transparency.

Triangles

The triangle is the fundamental construction element for 3D graphics. In fact,by juxtaposition of triangles one can approximate any continuous surface. In Processing, however, the trianglesare specified in 2D by the primitive triangle() , whose six parameters correspond to the coordinates of thevertices in the image window. Even though each triangle is defined in 2D, it can be rotated and translated in the 3Dspace, as it happens in the Processing sketch void setup(){ size(200, 200, P3D); fill(210, 20, 20); }float angle = 0; void draw(){background(200); // clear image stroke(0,0,0);angle += 0.005; rotateX(angle);triangle(10,10,30,70,80,80); }

Questions & Answers

how to create a software using Android phone
Wiseman Reply
how
basra
what is the difference between C and C++.
Yan Reply
what is software
Sami Reply
software is a instructions like programs
Shambhu
what is the difference between C and C++.
Yan
yes, how?
Hayder
what is software engineering
Ahmad
software engineering is a the branch of computer science deals with the design,development, testing and maintenance of software applications.
Hayder
who is best bw software engineering and cyber security
Ahmad
Both software engineering and cybersecurity offer exciting career prospects, but your choice ultimately depends on your interests and skills. If you enjoy problem-solving, programming, and designing software syste
Hayder
what's software processes
Ntege Reply
I haven't started reading yet. by device (hardware) or for improving design Lol? Here. Requirement, Design, Implementation, Verification, Maintenance.
Vernon
I can give you a more valid answer by 5:00 By the way gm.
Vernon
it is all about designing,developing, testing, implementing and maintaining of software systems.
Ehenew
hello assalamualaikum
Sami
My name M Sami I m 2nd year student
Sami
what is the specific IDE for flutter programs?
Mwami Reply
jegudgdtgd my Name my Name is M and I have been talking about iey my papa john's university of washington post I tagged I will be in
Mwaqas Reply
yes
usman
how disign photo
atul Reply
hlo
Navya
hi
Michael
yes
Subhan
Show the necessary steps with description in resource monitoring process (CPU,memory,disk and network)
samuel Reply
What is software engineering
Tafadzwa Reply
Software engineering is a branch of computer science directed to writing programs to develop Softwares that can drive or enable the functionality of some hardwares like phone , automobile and others
kelvin
if any requirement engineer is gathering requirements from client and after getting he/she Analyze them this process is called
Alqa Reply
The following text is encoded in base 64. Ik5ldmVyIHRydXN0IGEgY29tcHV0ZXIgeW91IGNhbid0IHRocm93IG91dCBhIHdpbmRvdyIgLSBTdGV2ZSBXb3puaWFr Decode it, and paste the decoded text here
Julian Reply
what to do you mean
Vincent
hello
ALI
how are you ?
ALI
What is the command to list the contents of a directory in Unix and Unix-like operating systems
George Reply
how can i make my own software free of cost
Faizan Reply
like how
usman
hi
Hayder
The name of the author of our software engineering book is Ian Sommerville.
Doha Reply
what is software
Sampson Reply
the set of intruction given to the computer to perform a task
Noor
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Media processing in processing. OpenStax CNX. Nov 10, 2010 Download for free at http://cnx.org/content/col10268/1.14
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Media processing in processing' conversation and receive update notifications?

Ask