5 kyu

Rotations and reflections I

168 of 232geoffp
Description
Loading description...
Object-oriented Programming
Design Patterns
Geometry
Mathematics
Fundamentals
View
AllIssues4Questions2Suggestions2Show Resolved
  • Please sign in or sign up to leave a comment.
  • 4500zenja1 Avatar

    For Java I'm pretty sure JUnit 5 allows to put assertion messages into assert methods. With that, you can properly output the assert notes without workarounds or so (consult with JUnit 5 example on docs.

    About C++, Snowhouse actually allows to implement assertions as well, although in a more tricky way.

    Finally, these messages are crucial for true/false checking, because otherwise you can get obscure output about expected true and actual false without any sign on where was that message invoked or smth :/

  • 66  Avatar

    Language: C++
    Initial solution are completely empty and in turn generates errors.

    • geoffp Avatar

      That's intentional. For this kata, you have to write an entire class from scratch.

      Issue marked resolved by geoffp 17 months ago
  • Tokarak Avatar

    It is unclear what the inverse of a reflection is.

    With rotation, reverse can be defined as an operation to undo the operation, or an operation which of the opposite direction.

    I am however having problems in inversions of a reflection. If it is to bring back the operation to origin, then its the inverse of itself (which is mathematicaly correct but feels "too easy"); If it is the lexicon opposite, then it would be a flip of 90 degrees (eg. vertical -> horizontal). Neither currently works in my code, and until the ambiguity is cleaned up, it will be hard to bugfix.

    Part of the problem is that there are no inversions of a reflection in the visible tests. One additional test will fix this issue.

    • geoffp Avatar

      A reflection is its own inverse. Performing the reflection twice returns every point to its original position.

      Issue marked resolved by geoffp 3 years ago
    • Tokarak Avatar

      Apologies. Like any other "unresolvable" bug, it turned out to be a typo. I was unknowingly recalculating my return value using bugged out code, and did not notice. The disambiguity finally helped me narrow down the location of the bug.

      So please consider adding that one test line to the code. It's pathetic, I know, but it would have saved me over an hour of my time, by being certain the problem was in the code, not in my logic.

    • geoffp Avatar

      A sample test has been added.

  • Voile Avatar

    It's not clear which of the 45-degree diagonals correspond to forward diagonal and reverse diagonal respectively.

    • geoffp Avatar

      The description has pictures of all the transformations, and then lists their names, noting that the names are given in the same order as the pictures. I think that makes it clear which name goes with which picture. There is also an example test-case to further clarify which diagonal is the reverse one.

      Issue marked resolved by geoffp 4 years ago
  • erichlf Avatar

    Can't seem to pass Is_Rotation_and_Is_Reflection_Tests in c++. I checked the return value of both member functions and that looks correct, but the test still fails. Is there a third part of this test?

    • geoffp Avatar

      Is_Rotation_and_Is_Reflection_Tests just checks the return values of is_rotation() and is_reflection() for each of the 8 possible values; that's all.

      If you're still stuck, post your code here (with a Spoiler flag) and I'll try to figure out what the problem is.

    • erichlf Avatar

      This comment has been hidden.

    • 4500zenja1 Avatar

      This comment has been hidden.

      Question marked resolved by 4500zenja1 6 months ago
  • monadius Avatar

    Approved

  • Blind4Basics Avatar

    Very interesting one. But I think the description lacks something to make it a bit less cryptic (especially in Java ; I do not know C++)): that could explain the satisfaction rate which is abnormally low.

    Saddly, I can't really find suggestions to add... In Java, a first drawback is that your test class extends Dih4. That's quite unusual (at least on CW) and that conditiones a part of the tasks to complete with the constructors. Maybe you could add that the constants will be Dih4 instances too.

  • sv90 Avatar

    I have a Problem while declaring the constants: It seems like the constants have to be in a namespace Dih4 since they are called as Dih4::IDENTITY in the example code. On the other hand the example code expects a class Dih4. But I cannot have a class and namespace of the same name in the same scope. I also cannot declare the constants as static const members since the class is not completed at that point. What am I missing?

    Edit: Solved it. I just had to define the static members outside of the class.

    • geoffp Avatar

      Yes, the constants are meant to be static members of the class. But (this trips me up a lot too) declaring a static constant in a C++ class is like declaring a function signature: it doesn't actually generate any binary code, it just tells the compiler that this thing ought to exist.

      Question marked resolved by geoffp 8 years ago
  • dinglemouse Avatar

    The following transformation test expected result seems wrong (Java). All the clockwise/anticlockwise seem around the wrong way

    REFLECT_VERTICAL then REFLECT_FORWARD_DIAGONAL
    expected:<rotation 90 degrees []clockwise> but was:<rotation 90 degrees [anti]clockwise>
    

    And this one..

    REFLECT_VERTICAL then REFLECT_REVERSE_DIAGONAL
    expected:<rotation 90 degrees [anti]clockwise> but was:<rotation 90 degrees []clockwise>
    

    And...

    REFLECT_FORWARD_DIAGONAL then REFLECT_VERTICAL
    expected:<rotation 90 degrees [anti]clockwise> but was:<rotation 90 degrees []clockwise>
    

    And...

    REFLECT_FORWARD_DIAGONAL then REFLECT_HORIZONTAL
    expected:<rotation 90 degrees []clockwise> but was:<rotation 90 degrees [anti]clockwise>
    

    And this..

    REFLECT_HORIZONTAL then REFLECT_FORWARD_DIAGONAL
    expected:<rotation 90 degrees [anti]clockwise> but was:<rotation 90 degrees []clockwise>
    

    And...

    REFLECT_HORIZONTAL then REFLECT_REVERSE_DIAGONAL
    expected:<rotation 90 degrees []clockwise> but was:<rotation 90 degrees [anti]clockwise>
    

    And..

    REFLECT_REVERSE_DIAGONAL then REFLECT_VERTICAL
    expected:<rotation 90 degrees []clockwise> but was:<rotation 90 degrees [anti]clockwise>
    

    And...

    REFLECT_REVERSE_DIAGONAL then REFLECT_HORIZONTAL
    expected:<rotation 90 degrees [anti]clockwise> but was:<rotation 90 degrees []clockwise>
    

    ~~~

    If I make hacks to match all those transformation tests then everything else is OK and I am able to pass

    Time: 3788ms Passed: 6 Failed: 0
    
    • geoffp Avatar

      The (expected) results are correct as they stand.

      For example: REFLECT_VERTICAL takes the top left corner of the square to the top right corner; if we then apply REFLECT_FORWARD_DIAGONAL the top right corner stays put. So the overall effect is that of a 90-degree clockwise rotation.

      Remember that REFLECT_VERTICAL means the mirror line is a vertical line (so the actual displacement of each point transformed is horizontal); the other 3 reflections are named analogously. I realize that these names are slightly ambiguous; happy to take any suggestions on better ones.

      Issue marked resolved by geoffp 8 years ago
    • dinglemouse Avatar

      Oops. The names and everything else are fine as-is. The error was enitirely mine by doing this kata while sleepy and thinking the "then" transformation I needed was the one to get back to the IDENTITY instead of from the IDENTIY - which meant everything was right except all my 90 rotations were backwards :-(

      Sorry for your trouble.

      Nice kata by the way - It was a welcome change to code a class from scratch instead of just how to write some algorithm.