haplokuon / netDxf

.net dxf Reader-Writer
MIT License
981 stars 400 forks source link

add mirror method #344

Closed kchbpy closed 2 years ago

kchbpy commented 2 years ago

Add the method of generate mirror Matrix4.

kchbpy commented 2 years ago

Now we can use the matrix4 to make a mirror object

Matrix4 mirrorMatrix = Matrix4.Mirror2D(mStart, mEnd);

Line ll = new Line(mStart, new Vector2(20, 10));
doc.AddEntity(ll);
Line ll2 = (Line)ll.Clone();
ll2.TransformBy(mirrorMatrix);
doc.AddEntity(ll2);
haplokuon commented 2 years ago

These matrices will work for an arbitrary mirror plane, not only on the XY plane.

DavidWishengrad commented 2 years ago

I like the matrix. Unfortunately, my understanding is not up to snuff while you are discussing this. There was another recent post with code for mirroring, but I did not try it. I was curious at the time if the normals would be correct. either way, I do understand enough now to understand that what blew past me was indeed needing to do a transformation. After getting the points and bulges of plines I wanted to adjust the bulge factor of legs to represent a rounded radius value. I had all of the info, thanks your examples, but could not reverse the math, and then realized I could make an arc from the data and convert it to pline with your ToPolyline2D method and read the value there and then change the bulge on the pline to match. I was like, great, that will work (though I have not had the time to try, but I am 99.99% sure it will). with solution in hand and no time to code I thought to myself, great, he really made it easy. Then, how on earth did he really do it. As one of my sons who teaches advanced math was unable to reverse the math. Ah, so I peeked in to your code and there was the transformation, (the base plane, which had been working by default and as such was an included variable the entire time that was going unnoticed) and you were adding that info that needs to be added to do a correct calculation. I just though your should know some of us are barely on the edge and able to peek over. :) It's like I cannot easily build a car radio, but I can I could possibly do a decent job of installing it with the correct advice. I don't know what I am doing, but your stuff just work and works. I can see the speed. Nothing added that is not really needed. Your methods make good logical sense.

haplokuon commented 2 years ago

@DavidWishengrad Well, thank you. What has not been very clear is if you were making a question, if it's the latter juat open a discussion and I will try to answer.

DavidWishengrad commented 2 years ago

I was just running my mouth and trying to stay focused. Thank you for your patience and kind words.

On Sat, May 28, 2022, 9:22 AM Daniel Carvajal @.***> wrote:

@DavidWishengrad https://github.com/DavidWishengrad Well, thank you. What has not been very clear is if you were making a question, if it's the latter juat open a discussion and I will try to answer.

— Reply to this email directly, view it on GitHub https://github.com/haplokuon/netDxf/pull/344#issuecomment-1140292093, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABINBYCPQRO23T3L7GCVE3TVMJB3JANCNFSM5KCTRTEA . You are receiving this because you were mentioned.Message ID: @.***>