Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please solve my doubts and explain the codes in easy understanding way dont comment 5. (4) Inheritance: It is desired to write a class hierarchy
please solve my doubts and explain the codes in easy understanding way
dont comment
5. (4) Inheritance: It is desired to write a class hierarchy for a set of graphics shapes, all of which have a position and orientation in 3D space, and which need to implement a method to draw themselves. The geometric objects are: Point, Line, Plane, Cube, Ellipsoid, Quadric, Cone, Cuboid. (a) Draw a likely class hierarchy. (b) Design the base class. (c) Explain why, by using a base class and hierarchy, the process of adding a new subclass, such as a Sphere, is greatly simplified. 5 BaseObject is the base class. Each of Point, Line, Plane, Cuboid, Quadric would inherit from BaseObject. Cube might inherit from Cuboid since a cube is a" cuboid. Likewise Ellipsoid and Cone might inherit from Quadric because these are special cases of Quadric (i.e. the "is a" relationship is satis- fied). However even here we have to be slightly careful since the more general Cuboid and Quadric may implement functionality that is not appropriate for the more specialised Cube, Ellipsoid and Cone. These objects could be moved up to inherit directly from BaseObject, at a cost of having to reimplement some functionality common to (say) Cuboid and Cube. b class BaseObject { public: // constructor, sets 3D position and orientation BaseObject (Vector v, Rotation r); // set 3D position and orientation void SetPose (Vector v. Rotation r); Set pose // we can write a member function to return position and // orientation simultaneously by exploiting side-effects // caused by passing by reference. void Get Pose (Vector& v, Rotation& r); 7/ GetPose can modify input v and r! If V and r are // initialised, obj.GetPose (v. r) will get v and I // equal to the position and orientation of obj. // draw to graphics window virtual void Draw(); --> why use this tine? private: Vector pos; please explain these words Why use 8 and 9 10 11 12 get pose 3 please explant 15 16 17 1N 19 20 21 Rotation rot; 22 3: 23 Listing 8: BaseObject.h Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started