The MASM Forum

General => The Workshop => Topic started by: Farabi on June 17, 2012, 01:27:08 AM

Title: [3D Graphic]Normals of a Face
Post by: Farabi on June 17, 2012, 01:27:08 AM
If a face rotated, is the normals rotated too? Im trying to determine the Front and Back faces.
Title: Re: [3D Graphic]Normals of a Face
Post by: dedndave on June 17, 2012, 03:24:58 AM
not sure what you mean by "normals"
but - this is something i'd like to learn about, too   :P
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 17, 2012, 03:52:25 AM
Farabi,

The normal to a plane is the vector perpendicular to the plane. It think it is also more accurately described as the cross product of the two vectors that are given for describing the plane (its's been a long time). This gives the normal vector a direction which can be used to describe the front or back of the plane (the normal vector starts at the intersection of the plane defining vectors and proceeds outward from the front of the plane (or face)).

Now the question relates to rotation of the plane. It all depends on which vector is chosen for the rotation. You can rotate around the normal vector, in which case the normal vector does not rotate in the sense that it changes any of its values (the point and direction), but can you consider that it rotates like a rifle  bullet?

If you rotate around any other vector such as one of the plane defining vectors or some other vector in the plane or intersecting the plane (or even a vector that is parallel to the plane) then the normal would rotate in the sense that its values would change (the point and direction).

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 17, 2012, 04:59:37 AM
Farabi,

Please remember that I am talking about Analytic Geometry concepts here, I have not dealt with 3D graphics and I know that in 2D graphics you are dealing with the 4th quadrant (y increasing as you go down the screen x increasing as you go right). 3D graphics may have even other differences.

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: FORTRANS on June 17, 2012, 05:54:34 AM
Hi,

   In 3-D graphics, objects can be made from polyhedra.  You
can use two edges of a polyhedron to generate a normal.
If when creating the polyhedra, you maintain a fixed ordrering
of the vertices (clockwise or counter-clockwise) for all
polyhedra, you use the normal to see if the visible side of
the polyhedron is pointing towards the viewer and needs
to be drawn (unless blocked of course).  Thus the normal
is defined in the object's coordinate system and is rotated
when the object is rotated.  (Whether the normal is stored
in the object definition or calculated for each test.)

Regards,

Steve N.

P.S.  Please get the spell checker going again.  Sigh.

SRN
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 17, 2012, 07:38:25 AM
Steve,

Quote
P.S.  Please get the spell checker going again.  Sigh.

Did I screw up any spellings? FF does a pretty good job but not always. It doesn't help that I do not a touch type, and that half of the legends are worn off of the keys on this old laptop (I had been coding for 47 years and my former boss said I would be a REAL TERROR if I could touch type!)

Dave
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 17, 2012, 07:44:43 AM
Steve,

To my question about rotations, if you spin a flat plane about its normal like a top, does the normal rotate? This is not meant to be a trick question, just a question of nomenclature.

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: Farabi on June 17, 2012, 12:00:02 PM
Quote from: dedndave on June 17, 2012, 03:24:58 AM
not sure what you mean by "normals"
but - this is something i'd like to learn about, too   :P

Hi Dave,
On my term, a normals is where the face facing. For example, a normals of X-Y-Z format value, had a value of 0-1-0, it mean, it was facing directly to Y. and if 1-0-0 it is facing directly to X, where if you scale the normals, and add it with the origin place of a vertex, you can see it direction.
Title: Re: [3D Graphic]Normals of a Face
Post by: FORTRANS on June 17, 2012, 10:59:54 PM
Hi,

QuoteDid I screw up any spellings?

   No, I was having a bad day and needed the dictionary way
too many times.

Quote
To my question about rotations, if you spin a flat plane about its normal like a top, does the normal rotate? This is not meant to be a trick question, just a question of nomenclature.

   As a one dimensional construct, the vector will be rotated
and it won't make any difference in the end.  I.e. if you
represent the normal vector as a homogeneous vector,
it will be multiplied by the "spin" transformation matrix,
so that all of the arithmetic of a rotation will get carried out.
But you end up with the same vector as you started out with.
(Assuming I got your question correctly.)  So, your choice,
does it get rotated or not?

Regards,

Steve N.
Title: Re: [3D Graphic]Normals of a Face
Post by: FORTRANS on June 19, 2012, 12:09:39 AM
Hi,

   Well that was botched.  Amazing what you think about
at 2:00am.  Sorry.

   Replace polyhedron with polygon.  A polygon is a
2-D object, a polyhedron is a 3-D object made up of
a number of  polygonal faces.  Think of a cube made up
of squares.  In 3-D graphics, the polyhedron is usually
called a mesh and is made up of triangles.

   A normal is a fancy (?) term for a perpendicular vector.
For a plane that is simple to envision.  As Dave said, for
a polygon, you can take the cross product of two edges
to produce a perpendicular vector, and normalize to get
the normal.

   About the spinning:  If you got a pizza pan and stuck
an arrow in it, you could rotate the fixed object around
the arrow.  If you painted the left side of the arrow green
and the right side red, you would see the arrow rotate
with the pan.

   But paint does not work with a one dimensional vector.
So when rotating (spinning) a plane about its normal, the
normal remains unchanged.  Even though you can pass it
through all the math of the transform.  So it is normally
(sorry) said to not rotate as it is identical before and after.

   Hopefully this is better than yesterday's.

...,

Steve N.
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 19, 2012, 12:16:56 AM
Steve,

I even pulled "Anlalytic Geometry A Vector Approach" (Wexler, 1964) from my library shelf and started reading. Ugh!

I used to enjoy this!

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 19, 2012, 12:26:01 AM
Quote from: FORTRANS on June 17, 2012, 05:54:34 AM
   In 3-D graphics, objects can be made from polyhedra.  You
can use two edges of a polyhedron to generate a normal.
If when creating the polyhedra, you maintain a fixed ordrering
of the vertices (clockwise or counter-clockwise) for all
polyhedra, you use the normal to see if the visible side of
the polyhedron is pointing towards the viewer and needs
to be drawn (unless blocked of course).  Thus the normal
is defined in the object's coordinate system and is rotated
when the object is rotated.  (Whether the normal is stored
in the object definition or calculated for each test.)

Steve,

I question "clockwise OR counter-clockwise". If you go clockwise, I think the  two edge vectors cross product will be reversed, you have to label the edges in a face counter-clockwise to get a normal (cross product) that points out.

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: FORTRANS on June 19, 2012, 12:45:49 AM
Hi Dave,

   That makes my brain hurt.  I think (thought) that CW/CCW
choice depended on your choice of left-hand or right-hand
coordinate system.  (?)  Will try to put that on my to do
list.

   A good discussion of this is in "Fundementals of Interactive
Computer Graphics", J. D. Foley and A. Van Dam, 1982.  I
think newer editions are out with a different title.

   Jim Blinn's three (?) books in the series "Jim Blinn's Corner"
are entertaining and discuss vectors and transformations.

   You can generate normals to a curved suface such as a
sphere by selecting a point on the surface and finding the
plane tangent to the surface at that point.  So a plane has
only one normal, while a sphere has any number of them.
Used for illumination effects.

Regards,

Steve N.
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 19, 2012, 01:32:22 AM
Steve,

Thank you for the computer age references. All my stuff is ancient.

Quote from: FORTRANS on June 19, 2012, 12:45:49 AM
That makes my brain hurt.

Why do you think I said Ugh!

Have to run to do some errands, be back this afternoon.

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: FORTRANS on June 19, 2012, 04:45:57 AM
Hi,

   I checked in the Foley and Van Dam book where they
noted that in their coordinate system, right-handed with
angles such that a 90 degree rotation will perform rotations
as follows.

                  Direction of
Axis of rotation  positive rotation
       x               y to z
       y               z to x
       z               x to y


   This is right-handed system with counter-clockwise angles.
They state that this is also the standard for vector algebra.
They then note that this is the opposite to the system used
by "Principles of Interactive Computer Graphics", by W. M.
Newman and R. F. Sproull, 1979.  (Clockwise angle definition.)

   One book I have defines the cross product based on
the sine of angle between the two vectors used to create
the cross product.  I think that assumes the standard
vector algebra angles.  Otherwise the cross product could
point in either direction based on the choice of a clockwise
or counter-clockwise angle system.  And his explaination
of how to calculate the cross product does not use angles.

   Finally, it is noted in an exercise:  "For the test to be valid,
the normal used for each polygon must consistently be inward
(pointing into the polyhedren) or outward."

   looks as if your system is consistent, you can choose any
convenient coordinate system idiom or its opposite.  Clockwise
or counter-clockwise angles, clockwise or counter-clockwise
vertex/edge ordering, and left or right handed axis placement.

Cheers,

Steve N.
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 19, 2012, 09:48:11 AM
Steve,

That makes sense. I am familiar with both methods.

My dad taught me electronics as he learned it in the 20's 30,s and 40,s left hand rule, current flow from positive to negative, with the diode arrow in schematics. Nowadays, it is more correctly the electron flow from negative to positive, but the diode (and transistor) arrows remain as a relic of the past. With the old left hand rule, current flow (+ to -) through a coil in the direction of your left hand fingers wrapped around the coil, meant that the north pole of the magnetic field (center of the coil) was in the direction of your thumb or up, the same as if you wrapped your left hand fingers around one of the wires in the coil with the thumb in the direction of the current flow then the finger tips (in  the center of the coil) would point up (north). The right hand rule, however covered the mathematics and geometry.

As far as the cross product goes, use determinants for the value, use the right hand rule (rotate one planer vector counter-clockwise to the other planer vector and the thumb points out (is the normal).

Kind of makes sense to allow either, but on some severely convoluted surfaces, where only polygon vertex coordinates  were known, it might be difficult to visualize just what was IN and what was OUT.

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: dedndave on June 19, 2012, 10:05:15 AM
20's ? - he must be a real OT   :P
spark-gap and all that

in physics class, they taught us the right-hand rule using i, j, and k
i never did get a good explanation as to why x, y, and z weren't good enough - lol

(http://programmedlessons.org/VectorLessons/vch12/ijkAxes.gif)

of course, x, y, and z are axis'
i, j, and k are vectors   ::)

the arrow you are talking about...
the arrow shows the direction of "conventional current flow", as opposed to "electron current flow"
which really reflects the way solid state devices work
a "hole" or "depletion" leaves an empty spot for an electron to fill
so - the arrow points in the direction of travel for holes   :P

when i was a teenager, i struggled a little with transistors
because i was raised on vacuum tubes - lol
later on, FET's came along and made the world right again - sorta
by that time, i was comfortable with transistors and had to re-learn tubes   :lol:
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 19, 2012, 01:46:39 PM
Dave,

He started out with Crystal radios, the old germanium crystals and cat whiskers (I think). He never got into spark gap transmitters(per-se). He served in the Signal Corps during the war (in Detroit) in research and suppression of radio interference, especially the noise suppression of ignition systems for tanks and jeeps.

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: dedndave on June 19, 2012, 03:06:27 PM
very cool
i think we all wound our wire around a toilet paper roll at one time or another - lol
fortunately, we had 1N34 and 1N60 diodes
no farting around with a cat whisker

i was raised not too far from Detroit
that's where we used to go to take our FCC exams
Title: Re: [3D Graphic]Normals of a Face
Post by: dedndave on June 19, 2012, 03:17:37 PM
i hope your last name isn't Wilson   :biggrin:

(http://img542.imageshack.us/img542/597/fewilson1922.png)

what ??? - that's not MY dad - i don't know the guy   :lol:
Title: Re: [3D Graphic]Normals of a Face
Post by: KeepingRealBusy on June 20, 2012, 09:48:27 AM
Dave,

Interesting find! No, not my dear ol' dad.

Dave.
Title: Re: [3D Graphic]Normals of a Face
Post by: dedndave on June 20, 2012, 08:13:30 PM
i bet that guy had all the gals, in his day - lol
Title: Re: [3D Graphic]Normals of a Face
Post by: Farabi on June 20, 2012, 09:50:54 PM
Quote from: dedndave on June 20, 2012, 08:13:30 PM
i bet that guy had all the gals, in his day - lol

Sounds like had a lamborghini  :lol:
Title: Re: [3D Graphic]Normals of a Face
Post by: dedndave on June 21, 2012, 03:17:53 AM
he had a crystal set that was only good for 10 miles   :lol:

when i was a kid in Michigan, i could get stations as far as Oklahoma City (at night) on my crystal set
of course, it was one of those 250 KW transmitters   :P
Title: Re: [3D Graphic]Normals of a Face
Post by: xanatose on July 09, 2012, 10:22:12 PM
A Point (vertex) is in the Form
T(x,y,z,1)

A normal is not a point or vertex, but a direction. So the form for a normal is:
T(x,y,z,0)

When you multiply a vertex by a 4x4 matrix. It will move its position. When you multiply a normal by a 4x4 matrix, it will just cause a rotation. IF is in the form (x,y,z,0).

Title: Re: [3D Graphic]Normals of a Face
Post by: Farabi on July 24, 2012, 11:21:15 PM
I tested it, it is rotated. So when you rotate an object, the object normals is rotated, or should be rotated.