PDA

Click to See Complete Forum and Search --> : 3D World


MDK Hunter
Nov 26th, 2000, 10:39 AM
Hi!

I have a plain, that explains by 3 points. How I can find normal to this plain?

Thanks.

kedaman
Nov 26th, 2000, 01:37 PM
_ _ _
3 points, a b and c:

of which you take two vectors:
_ _ _ _ _ _
d = a - b and e = a - c
_
and take the crossproduct f of them, which should be the normal
_ _ _
f = d X e

parksie
Nov 26th, 2000, 02:49 PM
What's the crossproduct again? I know the dotproduct but can't remember this one :(

kedaman
Nov 26th, 2000, 06:13 PM
The crossprodukt is the normal vector to the plane defined by two base vectors, the length of the vector is the area of the plane, that the base vectors holds.
mathematically you do this by a determinand with 3 rows, so you can do this programatically:

Type vector3
x As Single
y As Single
z As Single
End Type

Function CrossProduct(A As vector3, b As vector3) As vector3
With CrossProduct
.x = A.y * b.z - b.y * A.z
.y = A.x * b.z - b.x * A.z
.z = A.y * b.x - b.y * A.x
End With
End Function

The best part is of course, that you don't need to use any slow trigs! :D

MDK Hunter
Nov 27th, 2000, 08:56 AM
Ok, I have a normal can you say how I can determine this plane is visible or not.

Today I use math for angle betveen vectors, but it seems not powerful...
Can you help?

Fox
Nov 27th, 2000, 09:43 AM
You can use the positions:

If (Vertex(v1).X - Vertex(v0).X) * (Vertex(v2).Y - Vertex(v0).Y) - (Vertex(v1).Y - Vertex(v0)) * (Vertex(v2).X - Vertex(v0).X) < 0 Then
'Is visible
End If

Hope this helps :)

MDK Hunter
Nov 27th, 2000, 12:42 PM
Ok, thanks, I tryed this.
But one more question
equation of thratsforming X,Y,Z to perspective view X,Y

New_X = ((256 * x) / (z + Zoff)) + Xoff
New_Y = ((256 * y) / (z + Zoff)) + Yoff

where x,y,z - coordinates of points
Zoff,Xoff,Yoff is center of screen in 3d

Can anybody explain litle more abouut this math?
Thanks.

Fox
Nov 27th, 2000, 02:34 PM
Semms to be a translation matrix for me... Well you can calculate the position of a pixel in 3D-view with that formula... coz the middlepoint of your view must be the middle of your screen you need the offset coordinates which are at ScreenWidth / 2, ScreenHeight / 2. 256 is the FOV (field of view) which describes what angle you see, normal is around 90 degrees.

For any questions just ask...

kedaman
Nov 27th, 2000, 04:09 PM
Looks like a way to display a isometrical (without perspective) projection on the screen. That means there is no horizon, no point to which all parallell lines concur.
The view angle is also fixed in both axis

Koralt
Nov 28th, 2000, 05:19 PM
New_X = ((256 * x) / (z + Zoff)) + Xoff
New_Y = ((256 * y) / (z + Zoff)) + Yoff


I wouldn't advise you use 256 as the number, but yes, that is very definitely normal 3D projection code (not iso). Here goes:

The 256 is a semi-arbitrary constant. It actually ends up representing the viewfield: This *should* be something like half of the screensize times the Sine of the viewfield size. I actually recommend a viewfield of 90 degrees, and thus, instead of 256 you would use half of the width of the screen (for both.)

Zoff is the Z position of the viewer. There are better ways of doing that (z + Zoff twice? What's the point? Add Zoff first!!!).

Xoff and Yoff are the screen positions of the center of the view screen. In the case of VB, if you're drawing in a picture box, Xoff would be half the Width and Yoff half the Height. If it's a form, or the whole screen, same goes.

MDK Hunter
Nov 29th, 2000, 12:29 PM
New_X = ((256 * x) / (z + Zoff)) + Xoff
New_Y = ((256 * y) / (z + Zoff)) + Yoff

In source I finded, that z+Zoff is something like
My_position + Screen_Position.

Anybody knows real Perspective Math?

kedaman
Nov 29th, 2000, 12:49 PM
well you could visit the "3d jommetry" thread
http://forums.vb-world.net/showthread.php?threadid=20846