Page 1 of 1

Mirror a polyline using DCAL

PostPosted: Thu Feb 11, 2010 9:06 am
by Joseph Baron
Does anyone have any hints on how to mirror a polyline (entpln) using DCAL?

Mirror in dcal

PostPosted: Thu Feb 11, 2010 6:03 pm
by rod_walker
I used the procedure setrotrel


Code: Select all setrotrel(mat,PI,y,topp);   {Mirror about apex}
     For j:= 1 TO 6 DO
     xformpt(p[j],mat,q[j]);
   
     END;


In the above mat is inbuilt type modmat. Rotation is PI (ie 180degrees). Y is the axis of rotation, in my case the 'y' axis. topp is the point about which rotaation occurs.

In my case I had 6 points in point array p which are mirrored int point array q. These are declared in the VAR sectioin of the procedure.
VAR
p,q :ARRAY [1..6] OF point;
mat :modmat;

PostPosted: Thu Feb 11, 2010 9:46 pm
by Joseph Baron
Thanks for the reply!

I was actually reading about setrotrel right before leaving the office and it sounded like that was what I was looking for, I'm just not familiar with using it yet. You showing it let's me know I was on the right track.

I will study your code and see if I can get it to work. Working with polylines for 2 days is a new entity type for me, I have my project normalizing the pverts so I know where 1 is at (minx, miny) no matter what the shape and have some linework added (from an existing project) to it so it's proved I can do with it what I need to, so far anyway.

Thank you again and I'll post back on the results...

PostPosted: Fri Feb 12, 2010 10:35 am
by Joseph Baron
Works like a charm! :D

Thanks again for your 'activity on the DDN'.

Polylines

PostPosted: Sat Feb 13, 2010 5:11 am
by rod_walker
Great.
It is only doing a mirror about the orthogonal axis.

PostPosted: Mon Feb 22, 2010 10:20 am
by Joseph Baron
Well this worked OK as long as there were no bulges in the polyline.

I'm now looking at how to make this work when the entpln has bulges.

poly_fix will order the pntarr I give it and when there are bulges in the entpln they get "moved" to a different side of the shape.

The bulge is still at it's original end points, but since the end points get re-arranged in poly_fix the bulge is repositioned and now has a different radius.

So what I'm looking for is a 'poly_fix' that will accept the entpln entity instead of a pntarr.

miiror polyline.

PostPosted: Wed Feb 24, 2010 5:47 pm
by rod_walker
the manual describes polyverts as the 'type used for copious data associated with polylines and surfaces of revolution.'
Code: Select all 
polyvert = record
adrr: pvtaddr;  { the address of polyvert in database}
next: pvtaddr;  { the address of the next polyvert in chain}
prev: pvtaddr;  { the address of the previos polyvert in chain}
shape: integer; { value may be either pv_vert or pv_bulge}
pnt:     point;             
bulge: real;       {takes a value between + and - infinity. If 0.0 a straight line}
nextpnt: point; { coordinates of next polyvert in chain}
last: boolean;   { if true the polyvert is last in chain and field .next =nil}

If the value shape = pv_vert then the bulge field is ignored. If the shape field = pv_bulge then bulge contains a real number. 0.0 indicates a straight line. A negative value indicates a curve to the left and a positive value a curve to the right.

You need to reverse the sign of bulge. ie multiply the bulge value by -1.0.

Regards
Rod Walker

PostPosted: Thu Feb 25, 2010 3:56 pm
by Joseph Baron
Thanks Rod,

It's not the mirroring that's holding me up, it's the 'normalizing' of the polyline that contains bulges that's presented a new issue.

Sending pnts to poly_fix works before updating the entpln to those pnts as long as the entpln only has straight verts. Now I'm wantng to get bulges into the mix.

So it comes down to a 'poly_fix' type function that will work with entpln that contains both straight and bulge.

poly_fix

PostPosted: Fri Feb 26, 2010 7:05 pm
by rod_walker
poly_fix works on an array of points, so should you only be looking at the vertices of your polyline? After mirroring are you combining the mirrored polylines to create a new single entity?

Regards
Rod walker