feisty meow concerns codebase  2.140
triangle.cpp
Go to the documentation of this file.
1 
2 
3 
4 /*****************************************************************************\
5 * *
6 * Name : triangle *
7 * Author : Chris Koeritz *
8 * *
9 *******************************************************************************
10 * Copyright (c) 1992-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
17 
18 #include "cartesian_objects.h"
19 #include "line.h"
20 #include "rectangle.h"
21 #include "triangle.h"
22 
23 namespace geometric {
24 
26 : _vertex_1(cartesian_point::origin()),
27  _vertex_2(cartesian_point::origin()),
28  _vertex_3(cartesian_point::origin())
29 {}
30 
32  const cartesian_point &vertex_2, const cartesian_point &vertex_3)
33 : _vertex_1(vertex_1),
34  _vertex_2(vertex_2),
35  _vertex_3(vertex_3)
36 {}
37 
39 : _vertex_1(to_copy._vertex_1),
40  _vertex_2(to_copy._vertex_2),
41  _vertex_3(to_copy._vertex_3)
42 {}
43 
45 
47 {
48  if (this == &to_copy) return *this;
49  _vertex_1 = to_copy._vertex_1;
50  _vertex_2 = to_copy._vertex_2;
51  _vertex_3 = to_copy._vertex_3;
52  return *this;
53 }
54 
56 { return line<double>(_vertex_1, _vertex_2); }
57 
59 { return line<double>(_vertex_2, _vertex_3); }
60 
62 { return line<double>(_vertex_3, _vertex_1); }
63 
65 
67 
69 
70 void triangle::vertex_1(const cartesian_point &to_set) { _vertex_1 = to_set; }
71 
72 void triangle::vertex_2(const cartesian_point &to_set) { _vertex_2 = to_set; }
73 
74 void triangle::vertex_3(const cartesian_point &to_set) { _vertex_3 = to_set; }
75 
76 bool triangle::inside(const cartesian_point &where) const
77 {
78 //cerr << "triangle::inside: not implemented" << endl << flush;
79 if (where.x()) where.y(); // bogus.
80  return false;
81 }
82 
83 double triangle::area() const
84 {
85 //cerr << "triangle::area: not implemented" << endl << flush;
86  return 5;
87 }
88 
89 } // namespace.
90 
91 /*
92 //temp
93 #include "warper.h"
94 using namespace geometric;
95 typedef rectangle_warper<double> chuzzo;
96 chuzzo beanburp = chuzzo(rectangle<double>(0, 23, 39, 1012),
97  rectangle<double>(8, 19, 92982, -2), chuzzo::BOTTOM_RIGHT,
98  chuzzo::TOP_LEFT);
99 typedef rectangle_warper<double>::horizontal_component horzo;
100 typedef rectangle_warper<double>::vertical_component verzo;
101 int frunk() {
102  horzo peen;
103  beanburp.separate_horizontal(chuzzo::BOTTOM_RIGHT, peen);
104  verzo neep;
105  beanburp.separate_vertical(chuzzo::TOP_RIGHT, neep);
106 }
107 */
108 
109 
110 
111 
112 
Provides a geometric point that use double floating points numbers.
numeric_type x() const
Definition: point.h:47
numeric_type y() const
Definition: point.h:48
Represents a geometric triangle.
Definition: triangle.h:29
line< double > side_1_2() const
Definition: triangle.cpp:55
line< double > side_2_3() const
Definition: triangle.cpp:58
triangle & operator=(const triangle &to_copy)
Definition: triangle.cpp:46
cartesian_point vertex_2() const
Definition: triangle.cpp:66
cartesian_point vertex_1() const
Definition: triangle.cpp:64
cartesian_point _vertex_1
Definition: triangle.h:56
cartesian_point _vertex_3
Definition: triangle.h:58
double area() const
Definition: triangle.cpp:83
cartesian_point vertex_3() const
Definition: triangle.cpp:68
bool inside(const cartesian_point &where) const
Definition: triangle.cpp:76
line< double > side_3_1() const
Definition: triangle.cpp:61
cartesian_point _vertex_2
Definition: triangle.h:57
Contains all of our objects for geometry and avoids name clashes.
Definition: angle.h:25