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 9 of 9

Thread: two quick question about glClipPlane

Hybrid View

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Pennsylvannia
    Posts
    103

    two quick question about glClipPlane

    the description claims you specify the 4 coefficients of a new clipping plane,
    Ax + By + Cz + D = 0
    Fair enough. But in what coordinate system is this plane constructed? Furthermore, shouldn't we get to say which side of the plane is in, and which is out? glClipPlane seems to include no parameters that specify which side to throw away.
    Striving for proficiency...

  2. #2
    Member Regular Contributor
    Join Date
    May 2001
    Posts
    349

    Re: two quick question about glClipPlane

    The coefficients (p1, p2, p3, p4) passed to glClipPlane are given in object coordinates (model space). They are immediately transformed by the inverse transpose of the current modelview matrix, i.e. transformed like normals, to eye coordinates (view space):
    (p1', p2', p3', p4') = (p1, p2, p3, p4) * M^-1

    Vertices get clipped if the dot product of the eye coordinates with this vector is negative, i.e. the positive side is in.

    p1' * xe + p2' * ye + p3' * ze + p4' * we >= 0

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Pennsylvannia
    Posts
    103

    Re: two quick question about glClipPlane

    The inverse tranpose of the modelview matrix? All descriptions I've read say simply the inverse. If it is supposed to be in model coordinates, this would make sense:

    given p = [p1', p2', p3', p4] = [p1, p2, p3, p4]M^(-1)

    and given V_e = M*V_m where V_m is the model coordinates, and V_e is the eye coordinates, then:

    (p)V_e = [p1, p2, p3, p4]M^(-1)M*V_m = [p1,p2,p3,p4]*V_m

    the result of that matrix multiplication being a 1x1 matrix who's one entry is the dot product of the plane coefficients, and the original eye coordinates.

    All makes sense! So why the transpose? Is that just a technicality required since openGL stores matrices in collumn major format?
    Striving for proficiency...

  4. #4
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,370

    Re: two quick question about glClipPlane

    If you consider the homogeneous plane P=t(a, b, c, d) defined by your normal N, and a point V=t(x, y, z, 1) on this plane, you have:

    tP*V = 0

    then if you consider M the modelview matrix that transform V in V':

    tP * inverse(M) * M * V = 0

    M * V is V'

    and


    tP * inverse(M) = tP'

    thus: P' = t(inverse(M))

    Note: t is is the transpose operator

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Pennsylvannia
    Posts
    103

    Re: two quick question about glClipPlane

    Shouldn't the last line be: P' = t(inverse(M))*P ???

    anyway, I believe I get it. I was earlier treating P as a 1x4 matrix instead of a 4x1 matrix. Either way works, they just use a 4x1 so we need to transpose the inverse of M as well.

    Thanks very much to both of you!
    Striving for proficiency...

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Pennsylvannia
    Posts
    103

    Re: two quick question about glClipPlane

    am I right in my suspicion that you could reverse the side thats clipped by using [-a, -b, -c, -d] instead of [a, b, c, d]? Its the same plane, but the dot product should have its sign flipped!
    Striving for proficiency...

  7. #7
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,370

    Re: two quick question about glClipPlane

    Quote Originally Posted by mikau
    Shouldn't the last line be: P' = t(inverse(M))*P ???
    Yes you are right, I wrote it too fast.

Posting Permissions

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