Grasshopper

algorithmic modeling for Rhino

I understood the IsParallel method of Vector3D takes account of direction. However, recent code does not supprot this. Has something changed recently?


In both the following sets of code the debugger breaks where I did not expect. i.e. A vector aligned in the positive World X is seen to be parallel to a vector in the negative World X

 

Dim rcV1Test As New Rhino.Geometry.Vector3d(1, 0, 0)
Dim rcV2Test As New Rhino.Geometry.Vector3d(-1, 0, 0)
If rcV1Test.IsParallelTo(rcV2Test) = True Then
            Dim BBreak As Boolean = True
End If

Views: 797

Replies to This Discussion

still like to know if the parallel method is supposed to return a true value irrespective of direction. 

 

The way I used to check if parallel and in same direction was to create a local plane using the reference vector as the normal and the start point of the vector as the origin. I then transformed the test vector to this plane. A negative z value for the transformed vector indicates that it is parallel AND in opposite direction to reference vector. 

try to multiply the vectors .....

I guess VB will accept an integer as a boolean, I think c# you have to explicitly convert.

From memory (I don't have time to check right now), IsParallelTo returns an integer, 1 if the vectors have same direction, -1 if opposite direction (ie parallel) and 0 if not parallel.  So I think you should change your code to

 

If rcV1Test.IsParallelTo(rcV2Test) = 1 Then

 

Hope it helps.

Thanks man. I'll have to check the rhinocommon sdk. I was using ctype to Boolean so I think u are right i need to return integer values. Using the plane transform as a check is pretty quick but always good to minimize code. U watching the rugby? Watching nz vs tonga right now.
Glad it helped.  I missed the rugby this morning but will be catching a few games.  Are you supporting USA?

IsParallelTo() doesn't return a boolean at all, it returns an integer. +1 equals parallel, -1 equals anti-parallel and 0 equals not parallel:

 

 

--

David Rutten

david@mcneel.com

Leusden, Holland

Nice sketch. My bad. I need to re-read the rhinocommon sdk again. Obviously vb.net was converting 1 and 0 to Boolean true and false and neglecting -1

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service