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.

Polygon-Midpoint of Edge to Vertex of Edge

Started by crckrjck, December 15, 2006, 05:50:26 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

crckrjck

Set first point for the midpoint of the edge of a triangle, quadragon, pentagon, hexagon, etc and set the next point for the half-length and direction of the first side.

3rd point sets orientation of the polygon.
;D

support

hmmm...okay so when, where and why would you use such an option for polygons?

crckrjck

#2
To draw a polygon centered on the end of a line, midpoint on a box or other polygon edge, from center or quadrant of circle, midpoint snap between 2 points,  . . .

I OFTEN need a box from a midpoint edge startpoint and end up drawing a box half sized from a midpoint snap and reselecting it from the far corner and resizing back across the midpoint start with scale or info box 'from handle'.

Same with Triangle. Have to draw a Trialngle of correct size, select it, set a handle on an edge at midpoint and move it where it goes. The command described would drawit in place in 3 easy points.

Come on Jerry, a little imagination . . .
;D

prl

Quote from: crckrjck on December 15, 2006, 05:50:26 AM
Set first point for the midpoint of the edge of a triangle, quadragon, pentagon, hexagon, etc and set the next point for the half-length and direction of the first side.
3rd point sets orientation of the polygon.

I'm missing the purpose of the 3rd point.  Doesn't the 2nd point define the orientation of a polygon?

crckrjck

2 points only create an axis if the polygon can be drawn from 'either direction', which would be important that it not be constrained to counterclockwise.

So the 3rd point flips the polygon to the desired side of the axis. Like 'tickmarks'.
;D

prl

#5
cj, maybe I understood what you are trying to do, maybe not.

I couldn't think of how to do the 3rd point easily so I have the polygon drawn on both sides.  Should be a simple matter for you to delete the one you don't want.

midpoly.d3m (the below code)

'Program: midpoly.d3m

' for cj - 15 Dec 2006
' intended for 2d work

input "Enter number of polygon sides ", n
if n < 3 then n = 3

npts = sys(1)
if npts <> 2 then
   sys(1)=0
   setpoint "set two points, 1)middle of edge , 2) vertex ", 2
end if
if sys(1)<2 then
  Message "Need to set two points.  Please run command again"
  end
end if

pointval cx, cy, cz, 1
pointval ex2, ey2, ez2, 2

sys(1)=0
dx = ex2 - cx
dy = ey2 - cy
dz = ez2 - cz
d = dx * dx + dy * dy + dz * dz

if d = 0 then
  message "error: 1st and 2nd points are identical, unable to continue"
  end
end if

d = sqrt(d)

'unit vector
di=dx/d
dj=dy/d
dk=dz/d

r = -d
rx = r*di
ry = r*dj
rz = r*dk

x2 = cx + rx
y2 = cy + ry
z2 = cz + rz

>polygonedge
  {
    <pointxyz [x2, y2, z2]
    <pointxyz [ex2, ey2, ez2]
    <Nside [n]
  }
 
sys(80)=0
n = sys(9)
getattr n, type
putattr n, type, 1

>mirror
{
<axis 4
<pointxyz [x2, y2, z2]
<pointxyz [ex2, ey2, ez2]
<type 1
}
sys(80)=0

end

crckrjck

That is it ! [short of a 3rd point].

Shouldn't be hard for them to massage that.
;D  ;D

prl


support

Nicely done...now lets see if we can do something with that. No promises mind you.

crckrjck

"Aim at the sun, and you may not reach it; but your arrow will fly far higher than if aimed at an object on a level with yourself. "
~Joel Hawes

QuoteThe core functionality of DC needs so much work that I would hope we could agree for the time being not to waste developers time fixing stuff that isnt broken.

It may seem that way, but even prl can crank out a useful [and bug free] piece of code while the coffee brews.

I think Troll and the betaphites are getting the code cleaned up with admirable success. At this rate V18 should hit the deck running.

DC still has a lot of market competition. In many ways it's behind the curve.

I think the bar should be constantly raised. If we ask for nothing new, maybe we'll  get it.
;D [cash value of this opinion $.02]