first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / graphiq / library / geometric / triangle.cpp
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
25 triangle::triangle()
26 : _vertex_1(cartesian_point::origin()),
27   _vertex_2(cartesian_point::origin()),
28   _vertex_3(cartesian_point::origin())
29 {}
30
31 triangle::triangle(const cartesian_point &vertex_1,
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
38 triangle::triangle(const triangle &to_copy)
39 : _vertex_1(to_copy._vertex_1),
40   _vertex_2(to_copy._vertex_2),
41   _vertex_3(to_copy._vertex_3)
42 {}
43
44 triangle::~triangle() {}
45
46 triangle &triangle::operator =(const triangle &to_copy)
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
55 line<double> triangle::side_1_2() const
56 { return line<double>(_vertex_1, _vertex_2); }
57
58 line<double> triangle::side_2_3() const
59 { return line<double>(_vertex_2, _vertex_3); }
60
61 line<double> triangle::side_3_1() const
62 { return line<double>(_vertex_3, _vertex_1); }
63
64 cartesian_point triangle::vertex_1() const { return _vertex_1; }
65
66 cartesian_point triangle::vertex_2() const { return _vertex_2; }
67
68 cartesian_point triangle::vertex_3() const { return _vertex_3; }
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