May 27th, 2014, 5:32 pm
QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: outrunPivot point could be an argument too, right? That would allow you to make the member function static.Maybe. Why do you want a static function?Ai, I think I misunderstood "pivot point". If we have a circle with radius 1 at {x,y} coordinates {10,1} (at the right on the x-axis) then we can do two rotations. We can rotate it 90deg ccw while keeping the circle's center at {10,1} -which wouldn't change a thing-, or we can rotate it 90deg ccw around the point {5,5} which would move the circle center to {9,10}. I thought the pivot-point was the point around which you would do the rotation. Together with the angle it would determine how to move the circle to a new location. You were calling the circle center {10,1} the pivot point, that's a property of the circle instance.Making a function static is telling the compiler that the function will do nothing with the data members of the object, not even look at them. It then becomes more like "normal function". Making a member function const tells the compiler that is won't change the objects data members, but it might read them. Telling the compiler what the function can do is similar to making thing const, private etc. Also, since static function don't do anything with data member, the compiler is not going to bother to pass a pointer to an object datameters to the function. Another thing I like is that you van use static member functions without having to instantiate an class.QuoteQuoteI think you can make it easier extendible by changing Rotate::rotate into a template member function. That way you can add new specializations for new shape types without having to modify the source fileGood idea!! QuoteEg you can then add this specialization somewhere in the new pentagon.hpp header filetemplate<>void Rotate::rotate(Pentagon& p5) { ... };This is a free function?How can we formally introduce pivot point to Pentagon? Does template specialisation ensure this automagically?This is either a regular member function, or a static member function.I think making as few assumptions as possible..Rotation matrix Gotta get this into the design.
Last edited by
Cuchulainn on May 26th, 2014, 10:00 pm, edited 1 time in total.