<< Chapter < Page Chapter >> Page >

Projections

Perspective projections

A perspective projection is defined by a center of projection and a plane of projection . The projector rays connect the points in the scene with the center of projection, thus highlighting thecorresponding points in the plane of projection. The [link] shows a section where the plane of projection produces a straight line whose abscissa is d , and the center of projection is in the origin.

By similarity of two triangles it is easy to realize that the point having ordinate y gets projected onto the plane in the point having ordinate y p y d z .

In general, the projection of a point having homogeneous coordinates x y z 1 onto a plane orthogonal to the z axis and intersecting such axis in position d is obtained, in homogeneous coordinates, by multiplication with the matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 d 0 . The projected point becomes x y z z d , which can be normalized by multiplication of all its element by d z . As a result, we obtain x d z y d z d 1

Parallel views

Parallel views are obtained by taking the center of projection back to infinity ( ). In this way, the projector rays are all parallel.

Orthographic projection

The orthographic projection produces a class of parallel views by casting projection rays orthogonal to the planeof projection. If such plane is positioned orthogonally to the z axis and passing by the origin, the projection matrix turns out to beparticolarly simple: 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 . Among orthographic projections, the axonometric projections are based on the possibility to measure the object along three orthogonalaxes, and on the orientation of the plane of projection with respect to these axes. In particular, in the isometric projection the projections of the axes form angles of 120 ° . The isometric projection has the property that equal segments on the three axes remain equal when theyare projected onto the plane. In order to obtain the isometric projection of an object whose main axes areparallel to the coordinate axes, we can first rotate the object by 45 ° about the y axis, and then rotate by 1 2 35.264 ° about the x axis.

Oblique projection

We can talk about oblique projection every time the projector rays are oblique (non-orthogonal) to the projection plane. In order to deviate the projector rays from the normal direction by the angles θ and φ we must use a projection matrix 1 0 θ 0 0 1 φ 0 0 0 0 0 0 0 0 1

Casting shadows

As we have seen, Processing has a local illumination model, thus being impossible to cast shadows directly. However, bymanipulating the affine transformation matrices we can cast shadows onto planes. The method is called flashing in the eye , thus meaning that the optical center of the scene is moved to the point where the light source ispositioned, and then a perspective transformation is made, with a plane of projection that coincides with the planewhere we want to cast the shadow on.

The following program projects on the floor the shadow produced by a light source positioned on the y axis. The result is shown in [link]

Casting a shadow

size(200, 200, P3D); float centro = 100;float yp = 70; //floor (plane of projection) distance from center float yl = 40; //height of light (center of projection) from centertranslate(centro, centro, 0); //center the world on the cube noFill();box(yp*2); //draw of the room pushMatrix();fill(250); noStroke(); translate(0, -yl, 0); // move the virtual light bulb highersphere(4); //draw of the light bulb stroke(10);popMatrix(); pushMatrix(); //draw of the wireframe cubenoFill(); rotateY(PI/4); rotateX(PI/3);box(20); popMatrix();// SHADOW PROJECTION BY COMPOSITION // OF THREE TRANSFORMATIONS (the first one in// the code is the last one to be applied) translate(0, -yl, 0); // shift of the light source and the floor back// to their place (see the translation below) applyMatrix(1, 0, 0, 0,0, 1, 0, 0, 0, 0, 1, 0,0, 1/(yp+yl), 0, 0); // projection on the floor // moved down by yltranslate(0, yl, 0); // shift of the light source to center // and of the floor down by ylpushMatrix(); // draw of the cube that generate the shadow fill(120, 50); // by means of the above transformationsnoStroke(); rotateY(PI/4); rotateX(PI/3);box(20); popMatrix();

Got questions? Get instant answers now!

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