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

Thread: Cube plane intersections points

  1. #1
    Intern Newbie
    Join Date
    Sep 2010
    Posts
    36

    Cube plane intersections points

    Hi everybody,

    Does anybody know o algorithm to compute the intersections points between a plane and geometric cube?

    Thanks,

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2010
    Posts
    11

    Re: Cube plane intersections points

    public IntersectionType Intersects(AAIntBox box)
    {
    float3 vector;
    float3 vector2;
    vector2.X = (Normal.X >= 0f) ? box.MinCorner.X : box.MaxCorner.X;
    vector2.Y = (Normal.Y >= 0f) ? box.MinCorner.Y : box.MaxCorner.Y;
    vector2.Z = (Normal.Z >= 0f) ? box.MinCorner.Z : box.MaxCorner.Z;
    vector.X = (Normal.X >= 0f) ? box.MaxCorner.X : box.MinCorner.X;
    vector.Y = (Normal.Y >= 0f) ? box.MaxCorner.Y : box.MinCorner.Y;
    vector.Z = (Normal.Z >= 0f) ? box.MaxCorner.Z : box.MinCorner.Z;
    float num = ((Normal.X * vector2.X) + (Normal.Y * vector2.Y)) + (Normal.Z * vector2.Z);
    if (num + D > 0f)
    {
    return IntersectionType.Front;
    }
    num = ((Normal.X * vector.X) + (Normal.Y * vector.Y)) + (Normal.Z * vector.Z);
    return num + D < 0f ? IntersectionType.Back : IntersectionType.Intersecting;
    }

    its written in C#, but it shouldn't be hard to port.

    EDIT:

    If you haven't guessed, a "float3" is a vector of 3 floats

Posting Permissions

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