Question: Specify, design, and implement a class that can be used to keep track of the position of a point in three-dimensional space. For example, consider

Specify, design, and implement a class that can be used to keep track of the position of a point in three-dimensional space. For example,

consider the point drawn at the top of the next column. The point shown there has three coordinates:

x = 2.5, y = 0, and z = 2.0. Include member functions to set a point to a specified location, to shift a point a given amount along one of the axes, and to retrieve the coordinates of a point. Also provide member functions that will rotate the point by a

specified angle around a specified axis. To compute these rotations, you will need a bit of

trigonometry. Suppose you have a point with coordinates x, y, and z. After rotating this point (counterclockwise) by an angle ? , the point will have new coordinates, which well call x? , y? , and z? .

The equations for the new coordinates use the cmath library functions sin and cos, as shown here:

After a ? rotation around the x-axis:

x? = x

y? = y cos(?)z sin(?)

z? = y sin(?)+z cos(?)

After a ? rotation around the y-axis:

x? = x cos(?)+z sin(?)

y? = y

z? = x sin(?) + z cos(?)

After a ? rotation around the z-axis:

x? = x cos(?)y sin(?)

y? = x sin(?)+y cos(?)

z? =z

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!