Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: 3d Maths

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Wollongong
    Posts
    3

    3d Maths

    Hi im pretty stupid when it comes to maths but i really need help with a couple of formulas.

    I need something that will allow me to get all of the points in a straight line in 3d .. i know 2d is y=mx+b but i have no idea what it is in 3d

    Also i need help in the point formula for circles in 2d and 3d .. i havnt done anymaths for a few years and i forgot all the stuff i learnt at school . If anybody can explain this in lamen terms or point me to a web page that would be great .

    Thanx heaps

  2. #2
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    UK
    Posts
    27

    Re: 3d Maths

    Hi,

    In 3D you can specify a line using a point on the line and a vector co-directed (ie parallel) thus giving any arbitrary point on the line.

    Say P is point on the line ie Px, Py, Pz.
    X is an arbitrary point on the line x, y, z.
    V is the co-directed vector Vx, Vy, Vz then in parametric form:

    X = P + tC where t represents all real numbers.
    Thus by varying t you move along the line.

    If you know 2 points on the line instead of a point and a vector then, V = (P1 - P2), and the above equation can be used.

    Written in standard form the equation joining two points P1(x1 y1,z1) and P2(x2,y2,z2) is:

    (x-x1)/(x2-x1) = (y-y1)/(y2-y1) = (z-z1)/(z2-z1)

    Rewriting with (x2-x1)=l, (y2-y1)=m, (z2-z1)=n

    (x-x1)/l = (y-y1)/m = (z-z1)/n

    The equation of a shere is:

    (x-x0)^2 + (y-y0)^2 + (z-z0)^2 = R^2
    where the sphere's origin is at (x0,y0,z0) and radius R.

    In 2D just remove the z bits.

    [This message has been edited by thelamberto (edited 07-30-2002).]
    ----------------------------
    Anthony Clare
    School of Engineering
    Cranfield University

  3. #3
    Intern Newbie
    Join Date
    Jun 2002
    Posts
    33

    Re: 3d Maths

    Hey,

    I am pretty good at the maths but only a beginner at OpenGL so I don't know if this is a good form in which to look at this but here goes.

    For 2D circles the easiest method is to define a angle (theta) Then all the points on a circle are:

    x=radius * cos(theta) + x centre of circle
    y=radius * sin(theta) + y centre of circle

    Then if you take theta from 0 - 2pi (360 degrees) you have all the points. If you want it in the form of y=mx+c it more tricky

    y= square root of((x- x centre of cicrle)^2 - radius^2 ) - y centre of circle

    where ^2 means squared

    for a line I prefer to think in vectors. Imagine drawing a line by starting at a point on the line then drawing in one direction. This is easily done in vectors:
    points on line = a + lambda * b

    where a is a point on the line, b is a vector in the direction of the line and lambda is changed in value to reflect all the points on the line. from - infinity to + infinity. So for example a line through (1,1,0) in the x direction is given by:

    point = (1,1,0) + lambda * (1,0,0)
    or x point = 1 + lambda * 1
    y point = 1 + lambda *0
    z point = 0 + lambda *0

    then increase lambda from -10 to 10 gets you a line 20 units long.

    hope this is clear not really suire I have made sense.

    For cicles in 3D I don't know have to think but you could just rotate and translate then draw 2D circle?

    Hope it helps,

    Fringe

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Wollongong
    Posts
    3

    Re: 3d Maths

    thanx heaps for your help guys im only a newbie and for 2 people to describe how to do it so quickly is great .. who knows maybe i will be coding the quake 5 engine one day ... ha ha thanks peoples

  5. #5
    Guest

    Re: 3d Maths

    No you won't.

Posting Permissions

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