Results 1 to 12 of 12

Thread: 3D World

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Russia
    Posts
    15
    Hi!

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

    Thanks.
    Vodka, womens, computer...

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    What's the crossproduct again? I know the dotproduct but can't remember this one
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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:
    Code:
    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!
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Russia
    Posts
    15
    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?
    Vodka, womens, computer...

  6. #6
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    You can use the positions:
    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
    Hope this helps

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Russia
    Posts
    15
    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.
    Vodka, womens, computer...

  8. #8
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    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...

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    Member
    Join Date
    Aug 2000
    Location
    USA
    Posts
    32
    Code:
    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.
    -Koralt

  11. #11

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Russia
    Posts
    15
    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?
    Vodka, womens, computer...

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    well you could visit the "3d jommetry" thread
    http://forums.vb-world.net/showthrea...threadid=20846
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width