I need to find the center of a triangle in 3D space, help!

I need to find the center of a triangle in 3D space, help!

Post by Ted Gres » Sat, 31 Jan 1998 04:00:00



I am creating my own graphics library that does alpha-blending,
anti-aliasing, tri-linear buffering, and all that stuff (software based)....

My only problem is I need to know how to rotate around the objects center,
so i need to know how to rotate around the center of a triangle!! Right now,
it is rotating around the origin and looks horrible.

Does anyone know how to find the center point of a triangle from the
coordinates of 3 vertices?? And does anybody know the formula (without
matrices! !yikes!) to rotate an object around a specific point? Like if i
wanted to rotate a triangle around point (2,2,1)??  [x,y,z]

Thanx for your help!!

 
 
 

I need to find the center of a triangle in 3D space, help!

Post by George Foo » Sun, 01 Feb 1998 04:00:00


On Fri, 30 Jan 1998 21:52:46 -0500 in comp.os.msdos.djgpp Ted Gress

: My only problem is I need to know how to rotate around the objects center,
: so i need to know how to rotate around the center of a triangle!! Right now,
: it is rotating around the origin and looks horrible.

Define `center' :).  There are several points you could mean.  I think
it's most likely that you mean the centre of gravity.  Finding this
is simple -- you just take the arithmetic mean of the values of each
coordinate, i.e. if your triangle is at (a0,a1,a2), (b0,b1,b2),
(c0,c1,c2) then the centre of mass is at ((a0+b0+c0)/3, (a1+b1+c1)/3,
(a2+b2+c2)/3).

: Does anyone know how to find the center point of a triangle from the
: coordinates of 3 vertices?? And does anybody know the formula (without
: matrices! !yikes!) to rotate an object around a specific point? Like if i
: wanted to rotate a triangle around point (2,2,1)??  [x,y,z]

Remember that in 3D you rotate around an axis, not a point.  While
it's possible to do it without matrices, I can't go into that here --
IMHO it will be far simpler if you just use matrices. :)  They're not
really hard to use at all, if you know the rules.

--


 
 
 

I need to find the center of a triangle in 3D space, help!

Post by Paul Derbyshi » Sun, 01 Feb 1998 04:00:00


Try comp.graphics.algorithms...

--
    .*.  Friendship, companionship, love, and having fun are the reasons for
 -()  <  life. All else; sex, money, fame, etc.; are just to get/express these.
    `*'  Send any and all mail with attachments to the hotmail address please.

 
 
 

I need to find the center of a triangle in 3D space, help!

Post by Shawn Hargreave » Sun, 01 Feb 1998 04:00:00


Quote:Ted Gress writes:
>Does anyone know how to find the center point of a triangle from the
>coordinates of 3 vertices??

The "center" of a 3d object is not a very well defined concept, but for
most purposes just averaging the three vertices would do the trick.

Quote:>And does anybody know the formula (without matrices! !yikes!) to rotate

an object around a specific point?

Translate it to the origin, rotate it around the origin, and then
translate back to the original position.

But why do you say "without matrices"? IMHO matrices are the only
sensible way to do something like this, because they provide an easy way
to concatenate the translations and rotation into a single transform
rather than having to do each operation as a separate step. They aren't
nearly as complicated as they seem when you first look at them, and can
make your code far more robust, flexible, and efficient.

btw. this sort of question is not appropriate for a djgpp newsgroup:
comp.graphics.algorithms would be a much better place to ask.

--

"Pigs use it for a tambourine" - Frank Zappa

 
 
 

I need to find the center of a triangle in 3D space, help!

Post by Ted Gres » Sun, 01 Feb 1998 04:00:00


Thanks for your help.
I'll see if my news server handles that. Thanks again!

=-)


>Try comp.graphics.algorithms...

>--
>    .*.  Friendship, companionship, love, and having fun are the reasons
for
> -()  <  life. All else; sex, money, fame, etc.; are just to get/express
these.
>    `*'  Send any and all mail with attachments to the hotmail address
please.


 
 
 

1. How to tell two 3d triangles which in infront?

if (x0, y0, z0) and (x1, y1, z1), any way to tell which triangle is
infront and which in behind?

I can do that with very complicated mathematical calculation, but I
prefer a better way for faster computing.

Your suggestion will be appreciated.

thanks,

bye.bye.
--

|   : | | | | |  ___| | | | |  ~{1????????????a?????~}         :   |
| o : | |< <  | |___  | |< <   17, Jalan Badam 1, Taman Cheras,       : o |
|   : |_| |_| |_____| |_| |_|  56100 Kuala Lumpur, Malaysia, Earth.   :   |

2. GVP Memory & Guru Rom

3. I need Ctrl-Ins in BC 3.1 again

4. Tech info on file systems

5. Help finding how much free space is on HD???????

6. HP95LX serial port help

7. Help finding how much free space is on HD

8. Extended deadline (May 1.) Distributed Object Security Workshop at ECOOP

9. Segmented line in 3D space

10. Newbie seeks help with rotating triangle program

11. help with: dir0001.<space><space>0000.00

12. 3d programming/ray casting - need help

13. need help with a 3d routine!!