|
ex4-12l.h - Example 4-12 Point and Line classes - Line Header file (ex4-12l.h) |
// File: ex4-12l.h – Line class header file
#ifndef LINE_H
#define LINE_H
#include "ex4-12p.h" // include Point header file
class Line
{
private:
Point p1;
Point p2;
double a, b, c; // coefficients for equation of a Line
public:
// Constructors
// Create Line using two Points
Line(const Point& pp1, const Point& pp2);
// Create Line using coefficients for the equation of a Line
Line(double c1, double c2, double c3);
// Create Line parallel/perpendicular to a Line through a Point
Line(const Point& p, const Line& l, const char* Line_type);
// Create horizontal/vertical Line through a Point
Line(const Point& p, const char* Line_type); // horiz/vert through pt
// Create an offset Line from a given Line
Line(const Line& l, double offset);
// Create Line though a Point with a given lenght and and angle
Line(const Point& p, double length, double angle);
// Print Line: equation, Points, and slope
void print(void) const;
// Accessor functions
double get_a(void) const
{
return a;
}
double get_b(void) const
{
return b;
}
double get_c(void) const
{
return c;
}
const Point& get_p1() const
{
return p1;
}
const Point& get_p2() const
{
return p2;
}
// Length of a Line (distance between two Points)
double length(void) const;
// Midpoint of a Line
Point midpoint() const;
// Slope of a Line
double slope(void) const;
// distance to a parallel Line
double distance_to_Line(const Line&) const;
// distance to a Point
double distance_to_Point(const Point&) const;
// x-intercept of a Line
double x_intercept(void) const;
// y-intercept of a Line
double y_intercept(void) const;
};
#endif
CIS27: Programming in C++ Instructor: Joe Bentley