Hi!
I have a plain, that explains by 3 points. How I can find normal to this plain?
Thanks.
Printable View
Hi!
I have a plain, that explains by 3 points. How I can find normal to this plain?
Thanks.
Code:_ _ _
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
What's the crossproduct again? I know the dotproduct but can't remember this one :(
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:
The best part is of course, that you don't need to use any slow trigs! :DCode: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
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?
You can use the positions:
Hope this helps :)Code: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
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.
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...
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
I wouldn't advise you use 256 as the number, but yes, that is very definitely normal 3D projection code (not iso). Here goes:Code:New_X = ((256 * x) / (z + Zoff)) + Xoff
New_Y = ((256 * y) / (z + Zoff)) + Yoff
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.
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?
well you could visit the "3d jommetry" thread
http://forums.vb-world.net/showthrea...threadid=20846