News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Plane Snap

Started by Dr PR, February 03, 2014, 11:08:09 PM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Dr PR

V23.0
Win 7 Pro 64

I have been trying to use "Plane Snap" (F7) to draw a line perpendicular to a grid surface. I Tried it half a dozen times from different positions and it only snaps to the nearest edge of the grid. In every case it was much closer to a facet in the grid surface than to the edge.

Would someone else test this and let me know the results?

Note: The grid was created with "Surface Connect."

I tried it with a simple plane (P) and it works. However, I am pretty sure that it worked with grids in the past.

Phil
DesignCAD user since 1987

samdavo

#1
Phil,
Some time ago I posted a "saddle" (using surface patch) with a couple of normals (aqua) drawn with spheres and cones (but from points on the surface).

I went back and tried to draw a normal from the tip of a cone to the surface.
Using F7 I seem to be able to draw ... any number of lines  eg the red and the green lines -  which (I assume) are snapping to the edge of the small grid-element nearest to where I clicked - as you are saying I think.   (2 cents).

I wonder (?) - IMAGINE THE CONE WASN'T THERE ...

perhaps if a sphere was drawn which was centred at the tip of the cone (i.e. the point you want to draw a normal from), and a radius the edge of the cone, then you would get the shape at the intersection - and the centre of this shape would be the point to join to make the normal to the complex grid.   

prl

#2
Quote from: Dr PR on February 03, 2014, 11:08:09 PM

use "Plane Snap" (F7) to draw a line perpendicular to a grid surface.

Phil,  the plane snap (F7) seems to work normally for me (not snapping to an edge) although it doesn't enforce the perpendicular aspect you are looking for.  Not sure it was ever meant for that (the perpendicular part).  Only snaps to the nearest plane relative to the cursor position in 3d space.  If the F7 is the last snap of a line command, that line isn't necessarily the shortest distance to the grid surface from the starting point of the line. See attached file.  It is your grid creation from earlier.  I drew several lines from the midpoint of the white line and plane snapped to the grid.  Those lines are in blue and all land on the grid using F7 depending on where your cursor is at the time when you finish the line command.

Maybe you are using it (F7) in a different sequence of commands from my simple test.

Bob P

This behavior was discussed about a year ago with regard to real planes (as opposed to grid entities).  The fastest work-around that I can think of is to use this macro.  I don't remember who did it.  :-[

'Program: perpplane.d3m

'draw a normal (perpendicular) vector from a point to three points defining a plane

SetPoint "Set three points for plane, 4th point for perp point not on the plane", 4
if Sys(1) < 4 Then end

Pointval x1 y1 z1, 1
Pointval x2 y2 z2, 2
Pointval x3 y3 z3, 3
Pointval x4 y4 z4, 4
sys(1)=0

'normal vector is defined as 
a = y1*(z2 - z3) + y2*(z3 - z1) + y3*(z1 - z2)
b = z1*(x2 - x3) + z2*(x3 - x1) + z3*(x1 - x2)
c = x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)

'equation for plane variable d
d = a*x1+b*y1+c*z1

denom = sqrt(a*a + b*b + c*c)

'unit normal vector is
au = a/denom
bu = b/denom
cu = c/denom

'distance from 4th point to plane
mag = -(a*x4+b*y4+c*z4- d)/denom

if mag = 0 then
   Message "point is coplanar"
   sys(1)=0
   End
endif

'draw the normal line from the 4th point to the plane intersection
> line
  {
  <pointxyz [x4, y4, z4]
  <pointxyz [x4+mag*au,y4+mag*bu,z4+mag*cu]
  }
 
end

prl

#4
Quote from: Bob P on February 04, 2014, 04:57:18 AM
I don't remember who did it.  :-[

I wrote it.  Generally that program works fine provided you know which plane in the grid surface is closest to the point not on the surface.  With complex undulating grids, that's not easy to figure out. 

If Phil describes what he needs, there are ways to find that specific plane within the grid surface construct.

And to complicate matters even more with grids, if they are rectangular grids then there is the invisible diagonal making two planes.  It could be as shown in graphic 1 or  graphic 2.  Unless you export and reimport using dwg/dxf (it will explode the grid into 3 point planes where needed), you will not know.

prl

#5
Let's have some fun.  Here is a DC challenge.

Using Phil's grid surface that I created in the attached file (grid_challenge.dcd), find the length and location of the line that starts and is perpendicular to the grid surface and terminates at the yellow point mark.  Post your answers (the location and length) and also include your drawing.

(For you professor types, show your work and you will be graded on neatness and sequence.  Ha, always wanted to say that given that my professors were smart but slobs.)


minstrel

Quote from: prl on February 04, 2014, 06:15:02 AM
Let's have some fun. 

Yea right...easy for you to say!

Anyhow, here's my submission.  As usual, an outer '3Dspace' approach on my part.  Actually it's just a shot in the dark but got to me thinkin' and that's always good! 

Used no macros so I'm looking forward to the results from those who do[did].  No doubt this can be solved with a few clicks...but, it was good gymnastics none the less.

I leave my results 'hidden' within the .dcd...thanks for the challenge!

prl

#7
Quote from: minstrel on February 04, 2014, 11:00:51 AM
I leave my results 'hidden' within the .dcd...thanks for the challenge!

Thanks for the work and nice presentation, Minstrel.  In your last step you found the correct 5 point improper plane (the magenta outline).   The true perpendicular line from the grid surface is the yellow one I've drawn next to yours. 

minstrel

Quote from: prl on February 04, 2014, 11:20:09 AM
The true perpendicular line from the grid surface is the yellow one I've drawn next to yours.

Cool...I was only off by a 'couple' of million miles [over time, of course] ::)

Looking forward to the 'true' approach/solution when all the submissions are in and graded.

prl

#9
Quote from: minstrel on February 04, 2014, 11:44:31 AM
Looking forward to the 'true' approach/solution when all the submissions are in and graded.

There will be a few ways to do this.

Hint 1:  A 3d graphical approach is to draw a sphere using the pointmark as the center.  Finding the right radius is the trick.  Too much radius and one penetrates the grid, too little radius and there is a gap.  If you get it just right, the sphere will kiss the grid.  But then again, I didn't do it this way.   ;D

Dr PR

Here is a refresher of how "Plane Snap" works with ordinary planes.

The Reference Manual says "Plane Snap" "Moves the cursor to the nearest location on the nearest surface and sets a point there." The nearest location may be anywhere within the surface of the plane or along the edges of the plane.

There are two different results you can get from this function:

1. From within the volume of space "above" the plane. First imagine the volume of space above the plane that would be generated if the plane was extruded through an infinite distance along a line perpendicular to the plane. This is the volume "above" the plane.

a. If the cursor is at any point in this region above the plane the "Plane Snap" function will snap to the closest point on the plane. If you start the "Line" (V) function, set a point in the region above the plane, and then use "Line Snap" a line will be drawn from the point perpendicular to the plane and ending at a point on the surface of the plane.

b. If your starting point is immediately "above" an edge of the plane "Line Snap" will snap to a point along the edge of the plane. If a line is drawn from a point "above" the edge the line will be perpendicular to the surface of the plane and will end on the edge of the plane.

Both situations produce lines perpendicular to the surface of the plane.

2. From a point outside the region above the plane. If your cursor is outside the region "above" the plane the "Line Snap" function will snap to a point along an edge of the plane. If you draw a line from a point outside the region above the plane "Line Snap" will end the line on an edge of the plane.

This line will be perpendicular to the edge of the plane but WILL NOT be perpendicular to the surface of the plane.

NOTE: Normally, from a point "above" the plane, a line drawn to the nearest point on the plane will be perpendicular to the plane. However, this is not necessarily what "Plene Snap" does. Any line or snap to the edge of a plane or grid facet is suspect - it may not actually be perpendicular to the surface of the plane/facet.

****

Actually, I think prl has solved my problem. "Plane Snap" draws from the current cursor position to the nearest plane or planar grid facet. It seems to be working correctly for me now. I suspect I was setting a point for the "Line" (V) function and then moving the cursor before pressing F7. It DOES NOT work from the last point you set!

Hey, it was late and I was getting tired.

Phil

PS: As for how to use the "Plane Snap" function I just gravity snap to a point on the grid surface (or plane), drive the cursor around with the "Arrow" keys until it looks like it is "above" the plane and press F7. It doesn't always work as I expected, but if it snaps to another facet or to a grid line or plane edge I try again until I get a line that is drawn to the interior of the surface of the desired facet/plane.

PPS: I really wish we had the option to limit this function to working only from within the region "above" the plane so any line drawn to the plane will be perpendicular to it. This is the only way I ever use this function. I can find perpendiculars to the edges of planes in other ways, but finding a perpendicular to the surface of the plane is difficult and time consuming using ordinary 3D geometry.

PPPS: Technically, geometrical "planes" do not have edges (they are infinite), but planar polygons do. This is a semantical problem in the DesignCAD documentation. The "Plane" (P) function DOES NOT draw a plane, it draws a polygon. The "Plane Snap" function DOES NOT snap to a plane, it snaps to a polygon.

A "Plane Snap" function should always snap to a point in the plane of a polygon, even if it is outside the surface area of the polygon. What the documentation call "Plane Snap" should actually be called "Polygon Snap." Of course, if you flunked geometry I suppose you might think a polygon is a plane.

The "Line Plane" function can be used to find points in the plane of a polygon that are outside the area of the polygon.
DesignCAD user since 1987

prl

#11
Quote from: Dr PR on February 04, 2014, 01:34:59 PM
The Reference Manual says "Plane Snap" "Moves the cursor to the nearest location on the nearest surface and sets a point there." The nearest location may be anywhere within the surface of the plane or along the edges of the plane.

Phil, a couple of things for you to ponder.

1.  Regarding the reference manual definition above, this was supposedly improved depending on the value of sys(1032).  The below is from the macros17.hlp file. 

Quote1032 - Plane Snap mode [0 or 1] (R/W) (V. 13)
This function controls the behavior of the Plane Snap command. When set to zero, the plane snap command snaps to the nearest point in the mathematical plane occupied by the nearest surface (but that point may not actually be on the surface).
When set to one, the plane snap command behaves normally, and always snaps to the nearest point on the nearest surface (default).

2.  But, as you will find out if you play along with the little grid challenge I have posed, regardless of the sys(1032) setting, the plane snap command doesn't really find the surface of improper rectangular planar grids.  It gets close but not 100%.

Edit:

And to make sure everyone understands what an improper rectangular planar grid is:  in the graphic below, the magenta (pink) rectangle is a grid facet.  It consists of 5 points (point 1 and point 5 are the same).  The 5 points do NOT lie in one plane.  Mind you they could but for this particular grid they don't.  Think of the magenta rectangle as a piece 4x8 plywood on a flat floor.  Three corners are on the flat floor, the fourth corner is pulled up from the floor.  Hence the sheet of plywood isn't flat, it is warped.  If you were to explode this grid, that magenta rectangle will become a DesignCAD rectangular planar region (aka a DesignCAD plane) but the 5 points still do NOT lie in one mathematical plane.  Hence I call that sort of a warped DC rectangular planar region an improper plane in terms of DC jargon.   


Bob P

What drive me a little crazy about "improper planes" is that they are mathematically ambiguous.  Each 4-point grid entity has two possible diagonal splits, and neither component lies in the same plane as either component of the other set.  It's no wonder that DC doesn't like to mix planesnap with grids.

Dr PR

Bob,

I think "Plane Snap" works OK with grids. You just have to be very careful where you position the cursor over a high density grid because the program does what it is supposed to do - snap to the nearest facet - and that may not be the one you had in mind.

Positioning the cursor can be very tricky with facets that are angles to three axes. To make things simpler you can always redefine the "Working Plane" to be the surface of the facet. Then it is easy to move the cursor "up" relative to the surface of the facet.

However, as you point out, and as prl has noted, grid facets may not be planar, and they aren't divided into two triangles, so you have an "improper" curved polygon. Who knows what "normal" means in this case, but the program does come up with something "perpendicular" to the grid surface. I would like to see the algorithm used for that!

A simple way to solve the problem would be to generate two triangles for the "rectangular" facet and snap to the nearest one. It may not be precisely on the curved surface, but close. And it does allow you to find a line perpendicular to part of the grid facet, which is the important part.

Phil
DesignCAD user since 1987

prl

#14
Quote from: Bob P on February 04, 2014, 03:21:21 PM
What drive me a little crazy about "improper planes" is that they are mathematically ambiguous.

BobP, here is a trick you can do with grids.  Make a copy of the grid, then "solid define" it.   Draw a small solid cube off to the side in 3d space (doesn't need to touch the grid).  Subtract the cube from the improper solid (the grid).  DC will rebuild the grid showing the diagonals.  See the graphic below.  Once you know which way the diagonals go, you can use the perpplane.d3m routine on the original intact grid.