Add 'Angle of Line' user function

Issue #318 new
Susan Spencer created an issue

Create a function angleOfLine(A, B) which returns the angle in degrees of the line from A to B. The angle of line is always positive, 0 <= angle < 360

The user can use this function anywhere an angle is required, e.g. to create a point at distance and angle, or to create a control handle for a curve.

Comments (10)

  1. Roman Telezhynskyi repo owner

    I think you forgot that for pattern very important thing is sequence.

    For your purposes we create special variables that contain angle value. Use them. My idea was to make variable for each real object we have in a pattern. If you will open object property you will find that program filter all such variables add show only allowed for the object.

    angleOfLine(A, B) which returns the angle in degrees of the line from A to B. The angle of line is always positive, 0 <= angle < 360

    I have two point C and D. I write angleOfLine(A, B). What will return the function? Stop parsing?

    Also, program designed in such a way that on each step object know only about objects that was created before in sequence.

    And last, right now we have no mechanism for parsing point name and returning value. it is not the same as just to parse variable or digits.

  2. Roman Telezhynskyi repo owner

    One thing I noticed from the XML schema was the regex being used for the names of drawing objects. It appears that an underscore ‘_’ is valid as part of a name. This would seem to conflict with the requirement to parse line length references within formula. E.g.

    I create some points with names: ‘A’, ‘A_B’, ‘B’, ‘B_C’ and ‘C’. I then draw a line between ‘A_B’ and ‘C’ This gives a line reference that I can use in formula ‘Line_A_B_C’ I then create a second line between ‘A’ and ‘B_C’. This also has a line reference that I can use in formula 'Line_A_B_C’ This is therefore ambiguous.

    The easiest fix would be to disallow underscore from object names. In fact, the problem is even easier to reproduce if I label a point ‘Line_A_B’, though I am less likely to do that by accident. This doesn’t cause a failure, Valentina just silently uses the first value that provides that name, however this could be very confusing, especially if the values were similar.

  3. Susan Spencer reporter

    Rules to prevent usage of symbols and prefixes which convey meaning (like _ and Line) are good practices in naming conventions. Is it complex to implement these rules at this time?

  4. Roman Telezhynskyi repo owner

    I against such practices in this case. This will break almost all patterns users made already. The only one possible option for us is to improve or replace math parser.

  5. Log in to comment