We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › help!It's simple to you!
Page Index Toggle Pages: 1
help!It's simple to you! (Read 535 times)
help!It's simple to you!
Mar 11th, 2009, 2:12am
 
what's X/Z surface?And what is uv coordinates?Please give an concise expression or a link to the reference,thank you!
Re: help!It's simple to you!
Reply #1 - Mar 11th, 2009, 5:31pm
 
Not knowing where you encountered those terms, it's impossible to know exactly how to help you, but:

To me, "X/Z surface" means "the plane formed by the X and Z axes, in a 3-dimensional coordinate system."  By extension, it could also be used to mean any plane parallel to the X/Z plane.  If that doesn't make sense for where you encountered it, then tell us more so we can help you.

UV coordinates are the name for a general technique of mapping a coordinate system onto any arbitrary surface.  Any three dimensional shape has a surface.  A sphere, a cylinder, your body, all of those have surfaces.  Those surfaces, although they are not flat, are still essentially two-dimensional in the sense that if you were a tiny ant crawling on that surface, you could only move along two axes (forward/back and left/right) and still stay on the surface.  So, surfaces are 2 dimensional, even if they're curved.

We observe that a flat plane (the simplest 2 dimensional surface) has an obvious mapping of coordinates onto every point on the plane: you establish an arbitrary X and Y axis, and measure any point's coordinates relative to that.  It seems reasonable to conclude, therefore, that other 2D surfaces ought to have coordinates too.  But we can't really call them X and Y because those labels are already taken for planar coordinates.  Also, regular straight X and Y axes aren't going to work on curvy surfaces because, well, the surfaces are curved.

So instead you define two arbitrary axes, which by convention are called U and V, and lay them onto the surface in whatever manner best makes your life easier.  Then you measure any point on the curvy surface relative to those axes to get your U,V coordinates.  If you do a good job of defining your axes, then your coordinates have the nice side effect of allowing you to make other types of calculations (distances, directions) just like you would in the plane.  Although these calculations aren't strictly equivalent to their euclidean counterparts, they are often close enough to be useful at least for U,V points that are relatively close together.

In practical terms, some examples help.  Consider the surface of a sphere.  Like, say, the earth.  The obvious U,V mapping there is the latitude, longitude system that gives us our GPS coordinates.  The latitude axis runs from the north pole to the south pole through Greenwich, England.  This axis has the historical name "the Prime Meridian."  The longitude axis runs around the earth's equator, starting from 0 degrees at the prime meridian, to 360 degrees by the time it goes all the way around to reach the prime meridian again.  So, the "U" axis is latitude, and the "V" axis is longitude.  Presto, you have mapped the earth.  Of course, these axes behave differently than the X and Y axes on the plane: X and Y extend infinitely in both directions, while latitude and longitude are bounded within +/- 90 degrees, and 0..360 degrees, respectively.

Or consider the surface of a cylinder (just the round part; don't include any end-caps).  Similar to a sphere, you can make one axis run up and down the length of the cylinder, and the other axis run around its circumference.

A torus (donut shape) will have one axis that is a circle that wraps around the donut going through the hole, and the other axis that is (again like the sphere) a circle going around the "equator".

Essentially, for any two-dimensional surface, the is usually a reasonable way to put a U and V axis on it, and thereby give coordinates to every point on the surface.

This is particularly helpful in computer graphics, because it means that you can map an image or other texture, which may come in the form of a rectangular array of pixels or color values, onto a non-rectangular surface.  By convention, this type of U,V mapping usually bounds U and V onto the unit square.  That is, U and V are both made to go from 0.0 to 1.0, and are stretched as necessary to fit onto the object being textured.

http://en.wikipedia.org/wiki/UV_coordinates
Re: help!It's simple to you!
Reply #2 - Mar 12th, 2009, 2:04am
 
Impressing,thanks a lot!I mean the expression in the tutorial http://processing.org/learning/3d/texturecube.html
here it goes:
// Given one texture and six faces, we can easily set up the uv coordinates
 // such that four of the faces tile "perfectly" along either u or v, but the other
 // two faces cannot be so aligned.  This code tiles "along" u, "around" the X/Z faces
 // and fudges the Y faces - the Y faces are arbitrarily aligned such that a
 // rotation along the X axis will put the "top" of either texture at the "top"
 // of the screen, but is not otherwised aligned with the X/Z faces. (This
 // just affects what type of symmetry is required if you need seamless
 // tiling all the way around the cube)
I don't quite catch the meaning of "rotation along the X axis will put the "top" of either texture at the "top"
of the screen, but is not otherwised aligned with the X/Z faces.",and want to figure it out.Can you help me?
Page Index Toggle Pages: 1