New tool: 'Mirror Point' or 'Symmetric Point'

Issue #138 resolved
Susan Spencer created an issue

Add functions to 'mirror' or create symmetric points.

Need function for vertical symmetry Need function for horizontal symmetry Need function for groups of points or entire pattern.

'Mirror' section mirror point tool mirror points tool mirror pattern tool

Comments (26)

  1. Susan Spencer reporter

    Create mirrored/symmetric point on opposite side of:

    1. one reference point and vertical line, plus point to 'mirror'

    2. one reference point and horizontal line, plus point to 'mirror'

    3. two reference points, plus point to 'mirror'

  2. Susan Spencer

    The user selects an existing point 'A' - this is point that will be mirrored
    The user defines the reference point 'B'
    The user selects a second reference point 'C' or enters 'angle1'

    The point 'A' will be mirrored on the opposite side of the line (B,C) or ray (B, 'angle1') by this method:

    The distance from B to A is calculated. The angle from B to A is calculated. The angle from B to C is calculated as 'angle1' if C was entered. The angle from B to A to 'angle2' is calculated.

    Point D is created from point B at distance(B, A) and angle('angle1' + angleOfVector(A, B, angle2))

  3. David Arnold

    Please tell me if I should open another issue for this:

    • Many times, patterns work on "halfs" or on one side only (sleeve).
    • It would be useful to be able to work with halfs/single side in the draw mode (less pattern maintenance work)
    • Then it would be useful to have the possibility to create a "mirrored" detail which could then be united with the union tool if necessary.

    I feel this is slightly different from the topic, so should I open another issue for this?

  4. Barbara Weberkind

    I have the impression that this isn't necessary, one can already do it, sort of. At least I just did: - created a new pattern, point B was the base point. - created point C as a point at a distance from B with an angle. - created point A as another point with distance and angle from B.

    As helper objects, I needed to create the lines from B to C and from B to A.

    Now I defined the mirror point of A, A1, mirrored along BC, really easily: A1 is another point with distance and angle from B, where the distance is the length of the line from B to A, and the angle is 2*AngleLine_B_C-AngleLine_B_A.

    This solution makes a mirrored point for A, but it is ugly because we have to create those helper lines and cannot even hide them after the operation. So, instead of making another tool, I would propose widening the number of values that can be used in formulas. Where today you can only use the length of an existing line in a formula, why not be able to just use the distance between two arbitrary points without having to create a line between them? Why should you have to first create a line between two points to use its angle in a formula, instead of just using the angle of the line implicitly defined by two points?

  5. Roman Telezhynskyi repo owner

    I have the impression that this isn't necessary, one can already do it, sort of.

    Yes, sort of. :) But this way is very slow.

    Where today you can only use the length of an existing line in a formula, why not be able to just use the distance between two arbitrary points without having to create a line between them? Why should you have to first create a line between two points to use its angle in a formula, instead of just using the angle of the line implicitly defined by two points?

    There is a reason why i did exactly like this. This is because of limitation qmuparser library. By default, the math parser library supports functions, but i don't see easy way to resolving point names to coordinates. The library require a pair: name and value. So, how you see we have internal variable with value we take from it. Also i am not sure we can create a custom function that will take strings (names of points) as arguments.

    I know that this is not perfect solution, but, rather, quick. And your proposal is, in theory, better, but i don't see now how to make qmuparser to resolve such names. I have wrote the author of original math library (we use own fork) and asked this question him.

    This solution makes a mirrored point for A, but it is ugly because we have to create those helper lines and cannot even hide them after the operation.

    Actually in the develop branch we have a tool that can help you.

  6. Roman Telezhynskyi repo owner

    Hi,

    Susan and Barbara what do you think about throwing away qmuparser and use instead Lua language? Not all language of course, but only part of it. Most time we need only evaluate formulas, but we also want to have functions like this LineLength(A, B). And for this a parser should support custom types. Here one good candidate luawrapper. We will port the project to Qt and left parts we really need. Looks promising. This even will be smoothly for users.

  7. Barbara Weberkind

    I am only slowly working my way into this, I don't by far have the same overview over the qmuparser library as you. But given that Lua is a complete language, it even has conditional statements. Imagine we could use those in expressions. If you have looked at the other 'pre-pattern' I submitted with the other error, it had 3 points for each side point, one for front, one for back, and one for symmetric in case people want to work front and back symmetrically. Imagine that could at least be one point defined with a conditional expression, 'if (symmetricFrontToBack) then this-distance else that-distance'....

    This is just to advocate a use case. I don't know about the ease/difficulty of implementing the switch from qmuparser to Lua. I would even have to read a lot before I would understand the limitation. If you think it could be done within a reasonable time, then maybe one should try it in a branch, then merge in when it works.

  8. Roman Telezhynskyi repo owner

    As i see now Lua solve one problem, but add another. qmuparser not only parse a string and return value, but also return string tokens. These tokens we use for translation a formula. And i don't see how to implement this in case of Lua.

  9. Susan Spencer

    Can you give me an example of a function and how it returns a string token? Wish I knew more about your code, but if you give me an example I can do some investigation.

  10. Roman Telezhynskyi repo owner

    I spoke with the author of muparser and think that we should left qmuparser for translation, but use lua for expression parsing.

  11. Susan Spencer

    Great idea to use Lua. HOWEVER...Slash-and-Spread and Mirroring are needed to make real patterns! And they are required for making tutorials and examples for each pattern system. I just spent an entire month on the road presenting Valentina and gathering feedback, and Slash and Spread is needed right now. And Mirroring is second behind Slash-and-Spread.

    Having functions like LineLength(A, B) made my prototype very powerful and allowed a lot of creativity. So this is a great idea to implement user functions, but tutorials and examples are needed so that means Slash-and-Spread development (and Mirroring!) comes first except for a major crash report.

  12. Roman Telezhynskyi repo owner

    HOWEVER...Slash-and-Spread and Mirroring are needed to make real patterns!

    I know, i know.

  13. Barbara Weberkind

    Hi Roman, thanks for adding the tool, the fix you have committed gives me a really good code example on what my pattern graph implementation does as well.

    The graph implementation, as it turns out, badly needed the tokens that qmuparser returns to examine them for dependencies.

    Now I just have to do that merge, but thanks anyway!!!

  14. Log in to comment