please write header file & source file separately Downloads × r Minor in Compute
ID: 3743430 • Letter: P
Question
please write header file & source file separately
Downloads × r Minor in Computer Sc SC 103MM (106 unri x Homework 1-2018 F xy D x pdf CSc 21200- 2018 Fall Homework 1 Due September 17th, 2018 You will need to submit a written report with part of your codes and your source code via Blackboard. You also need to bring in a hard copy of the report with part of your codes to the class on the day that this is due Name your header file as LastName(3 to 5 letters) FirstNamelnitial HW1.h and yo implementation file as LastName(3 to 5 letters) _FirstNamelnitial_HW1.c Note: You can only use iostream, cassert, cmath, cstdio, and cstdlib. cpp Create a class called Point with the following 1. Private members: x, y and z as double. 2. Write a default constructor and set the point to (0, 0, 0) 3. Write a constructor and set the point to user input, if z is not inputted 4. Write a copy constructor. 5. Write the set functions for each individual member, x and y together, and x, y, and z together. 6. Write the get functions for cach individual member. 7. Write a member function called print0 that print out the point. 8. Write a member function called distance0 that return the distance between the origin and the point. Write a member function calledtine(param) that return true if pt2 is on the same line as the origin and the point. Othcrwise, return false. Also return false if the origin and the 9. point do NOT make a line. 10. Write a member function called cross(param) that return a point that is the cross product of a pt2 and the point 11. Overload the addition (+) and the subtraction (-) operators. 12. Overload the output ( and input operators. 13. Write a non-member function called plane(param) that takes an array of three points and a point. Return true if that point is on the plane created by the static array of three points. Otherwise, return false. To find the plane i. Find u and v where u is pt2-ptl and v is pt3-ptl ii. Find the normal vector to the plane by using the cross product of u and v ii. Using the Point-Normal Form, the normal vector, and any of the three points, the equation of the plane is afx-xo) + by-yo) (cz-zo) 0, where , b, c> is the normal vector and P(xo, yo, Zo) is one of the three points. Thus, any points P(x, y, z) that satisfy this equation is on the plane. 14. Write a non-member function called square(param) that takes a static array of unique points and the size of the array. Return true if the array of points can create at least one square. Otherwise return false 15. Write a non-member function called centroid(param) that takes a static array of points and the size of the array and return the centroid of the array of pointsExplanation / Answer
public class Point
{
private:
double x,y,z;
public:
Point()
{
x=0;
y=0;
z=0;
}
Point(double a,double b)
{
x=a;
y=b;
z=0;
}
Point(double a,double b,double c)
{
x=a;
y=b;
z=c;
}
//copy constructor
Point(const Point &p2)
{
x=p2.x;
y=p2.y;
z=p2.z
}
setx(double a)
{
x=a;
}
sety(double a)
{
y=a;
}
setz(double a)
{
z=a;
}
setxy(double a,double b)
{
x=a;
y=b;
}
setxyz(double a,double b,double c)
{
x=a;
y=b;
z=c;
}
double getx()
{
return x;
}
double gety()
{
return y;
}
double getz()
{
return z;
}
print()
{
cout<<"Point X:"<<x<<endl;
cout<<"Point Y:"<<y<<endl;
cout<<"Point Z:"<<z<<endl;
}
double distance()
{
origin=0;
return sqrt(pow((origin-x),2)+pow((origin-y),2)+pow((origin-z),2));
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.