How to use a CollisionPlane ?

Good day,

I’m trying to use a collisionplane, to get collisions from a ray, but I’m afraid I can’t set it up right.
I need to know at which coordinates did the collision happen. And I need to cover a particular zone. And that is quite impossible to do with my current knowledge.

I need to find the closest waypoint to the mouse at one point (thus, collisionplane and collisionray).
The plane must cover all the waypoints. This is how I initiate the plane, and it is probably where I’m wrong, since I did it entirely relying on pure luck (I didn’t understand the documentation, so I did what I could from what I had) :

LPlane World::GetWaypointPlane(void) const
{
    Waypoints::const_iterator it  = waypoints.begin();
    Waypoints::const_iterator end = waypoints.end();
    LPlane              plane;

    for (; it != end ; ++it)
    {
      const Waypoint& wp  = *it;
      LPoint3   pos = wp.nodePath.get_pos();

      if (pos.get_x() < plane.get_x())
	plane.set_x(pos.get_x());
      if (pos.get_y() < plane.get_y())
	plane.set_y(pos.get_y());
      if (pos.get_x() > plane.get_w())
	plane.set_w(pos.get_x());
      if (pos.get_y() > plane.get_z())
	plane.set_z(plane.get_y());
    }
    return (plane);
}

This is what I do after detecting the collision to get the world coordinates of said collision:

  for (int i = 0 ; i < collisionHandlerQueue->get_num_entries() ; ++i)
  {
    CollisionEntry* entry = collisionHandlerQueue->get_entry(i);
    NodePath        np    = entry->get_into_node_path();
    LPoint3         pos   = entry->get_surface_point(np);

    if (!(planePath.is_ancestor_of(np.node())))
      continue ;
    pos.set_x(pos.get_x() + np.get_x());
    pos.set_y(pos.get_y() + np.get_y());
    pos.set_z(pos.get_z() + np.get_z());
    break ;
  }

And this is how I get the closest waypoint:

Waypoint* World::GetWaypointClosest(LPoint3 pos_1)
{
    Waypoints::iterator it        = waypoints.begin();
    Waypoints::iterator end       = waypoints.end();
    Waypoint*           best      = 0;
    float               bestScore = 0;

    for (; it != end ; ++it)
    {
      LPoint3 pos_2  = (*it).nodePath.get_pos();
      float   dist_x = pos_1.get_x() - pos_2.get_x();
      float   dist_y = pos_1.get_y() - pos_2.get_y();
      float   score  = SQRT(dist_x * dist_x + dist_y * dist_y);
      
      if (score <= bestScore || (bestScore == 0 && best == 0))
      {
	best      = &(*it);
	bestScore = score;
      }
    }
    return (best);
}

There has to be something wrong in those, but my non-existent understanding of Panda3D planes shields me from discovering it.
The resulting position seems legit, but when looking for the closest waypoints, it seems some of the axis may be reverted.

Could I get any help with this ?