pythonpanda3d

Simple plane intersection using Panda3D


While messing around with Panda3D to see if I can use it in order to solve some simple geometric problems, I've got this littel test done:

def def_planes_intersect():
    """Intersects the plane defined by the xy and xz axis'."""
    xy = Plane()
    xz = Plane((LPoint3f(1, 0, 1), LPoint3f(2, 0, 1), LPoint3f(1, 0, 2)))
    if xy.intersectsPlane((0, 10, 0), (1, 0, 0), xz) is True:
        print("works")
    else:
        print("doesn't")

It works as intended, but what I don't understand is how I can take the LPoint3f and LVector3f that define the intersection.

In the Panda3D docs it says:

intersectsPlane(from: LPoint3f, delta: LVector3f, other: LPlanef) → bool

Returns true if the two planes intersect, false if they do not. If they do intersect, then from and delta are filled in with the parametric representation of the line of intersection: that is, from is a point on that line, and delta is a vector showing the direction of the line.

What do they mean by from and delta are filled in?


Solution

  • So, while writing my question, I realized that I had to initialize an instance of LPoint3f and LVector3f and the method would fill them with the relevant data. I decided to post this seeing as there might be people out there that'll get as lost as me

    from panda3d.core import LPoint3f, Plane, LVector3f
    
    
    def def_planes_intersect():
        """Intersects the plane defined by the xy and xz axis'."""
        xy = Plane()
        xz = Plane((LPoint3f(1, 0, 1), LPoint3f(2, 0, 1), LPoint3f(1, 0, 2)))
        a = LPoint3f()
        av = LVector3f()
        if xy.intersectsPlane(a, av, xz) is True:
            print("works")
            print(f"{a}\n{av}")
        else:
            print("doesn't")
    

    Which prints the obvious result of:

    LPoint3f(0, 0, 0) 
    LVector3f(1, 0, 0)