bezier curves

This is a discussion on bezier curves within the Game Programming forums, part of the General Programming Boards category; coudl someone show me an example please. Like who one is supposed to create a curved surface. I chose x ...

  1. #1
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926

    bezier curves

    coudl someone show me an example please. Like who one is supposed to create a curved surface. I chose x control points, but how do I control the curve?

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    you need to calculate n intermediate points using your x control points and generate a line (for 2D) or a mesh (for 3D). NeHe has a bezier example. There are a few different ways to do the calculation, the most popular seems to be the using the bernstein polynomial, but there are alternative approches.

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    17
    I found this link helpful as well.

    Is there a way to choose control points if you know the curve and it's equation, but want to play with it a bit.

    All examples and articles speak of using the control points, but none really address how to arbitrarily choose them.

    thanks
    Last edited by just2peachy; 12-16-2004 at 09:56 AM.

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Here's the formula for a bezier surface with m*n control points called P.
    (u,v) are the surface parameters and they should be in the interval [0,1].

    Calculate as many points as you wish and then connect them with triangles.
    Attached Images Attached Images  
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    OK, the image didn't turn out that well when I saved it as gif.

    To use lightning on your surface you need to calculate normals
    to the surface. For this, to need to be able to derive the surface. Here's the formula for d/du and d/dv looks very similar.
    Attached Images Attached Images  
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  6. #6
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Hmm, I forgot the definition of B(u).
    This is called a Berstein polynomial and is defined as following:

    BTW, my suggestion is that you learn Bezier curves before starting to work with surfaces. If you need any matlab code I posted some here a while ago.
    Attached Images Attached Images  
    Last edited by Sang-drax; 12-16-2004 at 11:15 AM.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  7. #7
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    thanks I'll check it when I get home

  8. #8
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by just2peachy
    I found this link helpful as well.
    One thing about that site: It suggests using cross-product to obtain the surface normals:
    Quote Originally Posted by gamedev.net
    Now we have a way to describe two tangent vectors on each point on the surface. This mean that we will be able to calculate the normal vector of any point on the surface.

    In general, if you have two vectors, V={vx, vy, vz} and U={ux, uy, uz} then those two vectors can be 'crossed' to produce a new vector N={nx, ny, nz} that is orthogonal to both V and U (Two vectors beeing orthogonal means that the angle between them are 90°).
    I haven't studied multi-variable calculus yet, so someone please correct me if I'm wrong, but isn't

    grad f + (0,0,-1) a normal to the plane z = f(x,y)?

    Could there be some similar way to calculate normals to the bezier surface without cross product?
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  9. #9
    Registered User
    Join Date
    Oct 2004
    Posts
    17
    I'm not sure what the role of + (0,0,1) does. Could you explain what you mean by that?

    I think there are conditions to your proposal.

    Here's what MathWorld states:
    If grad f is nonzero, then the gradient is perpendicular to the level curve through (Xo,Yo) if z=f(x,y) and perpendicular to the level surface through (Xo,Yo,Zo) if F(x,y,z)= 0.

  10. #10
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Consider the surface z = f(x,y).

    Create a new function g(x,y,z) = f(x,y) - z. Then our surface is equivalent to g(x,y,z)=0.

    But g(x,y,z)=0 is a level surface, so grad(g) must be perpendicular to the surface.

    grad g = (dg/dx , dg/y , dg/dz ) = (df/dx , df/dy , -1) = grad f - (0,0,1)

    Hmm, the plus sign should've been a minus sign.
    Last edited by Sang-drax; 12-23-2004 at 03:11 AM.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Are B-splines composed of Bezier curves?
    By thetinman in forum Game Programming
    Replies: 4
    Last Post: 01-28-2009, 11:21 AM
  2. Bezier Curves where y = f(x)
    By thetinman in forum Game Programming
    Replies: 11
    Last Post: 12-27-2008, 10:21 AM
  3. What's the purpose of Bezier Curves?
    By thetinman in forum Game Programming
    Replies: 5
    Last Post: 10-06-2008, 09:38 PM
  4. Collision detection between bezier and ball.
    By CornedBee in forum Game Programming
    Replies: 1
    Last Post: 04-27-2006, 01:49 PM
  5. Attaching Cylinder to Bezier curve...
    By MipZhaP in forum Game Programming
    Replies: 5
    Last Post: 09-02-2004, 11:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21