Grasshopper

algorithmic modeling for Rhino

What makes a plane "invalid"?  I can't seem to create a "valid" Rhino.Geometry plane using the constructor "plane(a, b, c, d)".  For example, 

Plane p = new Plane(2,-8,5,18);

results in an invalid plane p.  But if I construct the same plane using point and normal as:

Vector3d v = new Vector3d(2, -8, 5);

Point3d pt = new Point3d(1, -2, 0);

p = new Plane(pt, v);

its all good.  p is now "valid".  For various reasons I'd like to be able to use the first call.  Thoughts?

     - Brian -

Views: 637

Replies to This Discussion

Hi Brian,

this is not quite my area of expertise (I didn't understand how a plane equation worked until I looked it up just now). According to the OpenNurbs source code, the Plane.IsValid check does the following:

  1. If the Plane Equation is invalid, the plane itself is invalid. A plane equation is only considered invalid if it has invalid numbers, any combination of regular doubles is considered valid.
  2. Then there's some stuff about handling planes very far away from the origin which I don't quite understand.
  3. Then it checks for right-handedness. However the Plane constructor should always create right-handed planes.
  4. Ultimately the equation normal is tested against the pane z-axis and if they are not aligned to within a very tight tolerance the plane is also considered invalid.

From this it follows that as long as you supply any doubles for the plane equation that are not all zeroes or, NaNs or RhinoMath.UnsetValue, you should end up with a valid plane. I'll need to debug into this (all the way from Grasshopper into RhinoCommon into rh_common into OpenNurbs which takes a long time.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

One quick fix is to do the following:

Dim plane As New Plane(2, -8, 5, 18)
Dim zaxis As Vector3d = plane.ZAxis
zaxis.Unitize()
plane.ZAxis = zaxis

I'll go about adding a unitize to the plane constructor as well.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Yup, that fixed it. The next RhinoCommon release will have a working equation constructor.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service