triangle.cpp

Go to the documentation of this file.
00001 #ifndef TRIANGLE_IMPLEMENTATION_FILE
00002 #define TRIANGLE_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : triangle                                                          *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1992-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "cartesian_objects.h"
00019 #include "line.cpp"
00020 #include "rectangle.cpp"
00021 #include "triangle.h"
00022 
00023 namespace geometric {
00024 
00025 triangle::triangle()
00026 : _vertex_1(new cartesian_point(origin())),
00027   _vertex_2(new cartesian_point(origin())),
00028   _vertex_3(new cartesian_point(origin()))
00029 {}
00030 
00031 triangle::triangle(const cartesian_point &vertex_1,
00032     const cartesian_point &vertex_2, const cartesian_point &vertex_3)
00033 : _vertex_1(new cartesian_point(vertex_1)),
00034   _vertex_2(new cartesian_point(vertex_2)),
00035   _vertex_3(new cartesian_point(vertex_3))
00036 {}
00037 
00038 triangle::triangle(const triangle &to_copy)
00039 : _vertex_1(new cartesian_point(*to_copy._vertex_1)),
00040   _vertex_2(new cartesian_point(*to_copy._vertex_2)),
00041   _vertex_3(new cartesian_point(*to_copy._vertex_3))
00042 {}
00043 
00044 triangle::~triangle()
00045 {
00046   WHACK(_vertex_1);
00047   WHACK(_vertex_2);
00048   WHACK(_vertex_3);
00049 }
00050 
00051 triangle &triangle::operator =(const triangle &to_copy)
00052 {
00053   if (this == &to_copy) return *this;
00054   *_vertex_1 = *to_copy._vertex_1;
00055   *_vertex_2 = *to_copy._vertex_2;
00056   *_vertex_3 = *to_copy._vertex_3;
00057   return *this;
00058 }
00059 
00060 line<double> triangle::side_1_2() const
00061 { return line<double>(*_vertex_1, *_vertex_2); }
00062 
00063 line<double> triangle::side_2_3() const
00064 { return line<double>(*_vertex_2, *_vertex_3); }
00065 
00066 line<double> triangle::side_3_1() const
00067 { return line<double>(*_vertex_3, *_vertex_1); }
00068 
00069 cartesian_point triangle::vertex_1() const { return *_vertex_1; }
00070 
00071 cartesian_point triangle::vertex_2() const { return *_vertex_2; }
00072 
00073 cartesian_point triangle::vertex_3() const { return *_vertex_3; }
00074 
00075 void triangle::vertex_1(const cartesian_point &to_set) { *_vertex_1 = to_set; }
00076 
00077 void triangle::vertex_2(const cartesian_point &to_set) { *_vertex_2 = to_set; }
00078 
00079 void triangle::vertex_3(const cartesian_point &to_set) { *_vertex_3 = to_set; }
00080 
00081 bool triangle::inside(const cartesian_point &where) const
00082 {
00083 //cerr << "triangle::inside: not implemented" << endl << flush;
00084 if (where.x()) where.y();  // bogus.
00085   return false;
00086 }
00087 
00088 double triangle::area() const
00089 {
00090 //cerr << "triangle::area: not implemented" << endl << flush;
00091   return 5;
00092 }
00093 
00094 } // namespace.
00095 
00096 /*
00097 //temp
00098 #include "warper.h"
00099 using namespace geometric;
00100 typedef rectangle_warper<double> chuzzo;
00101 chuzzo beanburp = chuzzo(rectangle<double>(0, 23, 39, 1012),
00102   rectangle<double>(8, 19, 92982, -2), chuzzo::BOTTOM_RIGHT,
00103   chuzzo::TOP_LEFT);
00104 typedef rectangle_warper<double>::horizontal_component horzo;
00105 typedef rectangle_warper<double>::vertical_component verzo;
00106 int frunk() {
00107   horzo peen;
00108   beanburp.separate_horizontal(chuzzo::BOTTOM_RIGHT, peen);
00109   verzo neep;
00110   beanburp.separate_vertical(chuzzo::TOP_RIGHT, neep);
00111 }
00112 */
00113 
00114 
00115 
00116 #endif //TRIANGLE_IMPLEMENTATION_FILE
00117 

Generated on Fri Nov 28 04:29:15 2008 for HOOPLE Libraries by  doxygen 1.5.1