triangle.cpp

Go to the documentation of this file.
00001 
00002 
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.h"
00020 #include "rectangle.h"
00021 #include "triangle.h"
00022 
00023 namespace geometric {
00024 
00025 triangle::triangle()
00026 : _vertex_1(cartesian_point::origin()),
00027   _vertex_2(cartesian_point::origin()),
00028   _vertex_3(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(vertex_1),
00034   _vertex_2(vertex_2),
00035   _vertex_3(vertex_3)
00036 {}
00037 
00038 triangle::triangle(const triangle &to_copy)
00039 : _vertex_1(to_copy._vertex_1),
00040   _vertex_2(to_copy._vertex_2),
00041   _vertex_3(to_copy._vertex_3)
00042 {}
00043 
00044 triangle::~triangle() {}
00045 
00046 triangle &triangle::operator =(const triangle &to_copy)
00047 {
00048   if (this == &to_copy) return *this;
00049   _vertex_1 = to_copy._vertex_1;
00050   _vertex_2 = to_copy._vertex_2;
00051   _vertex_3 = to_copy._vertex_3;
00052   return *this;
00053 }
00054 
00055 line<double> triangle::side_1_2() const
00056 { return line<double>(_vertex_1, _vertex_2); }
00057 
00058 line<double> triangle::side_2_3() const
00059 { return line<double>(_vertex_2, _vertex_3); }
00060 
00061 line<double> triangle::side_3_1() const
00062 { return line<double>(_vertex_3, _vertex_1); }
00063 
00064 cartesian_point triangle::vertex_1() const { return _vertex_1; }
00065 
00066 cartesian_point triangle::vertex_2() const { return _vertex_2; }
00067 
00068 cartesian_point triangle::vertex_3() const { return _vertex_3; }
00069 
00070 void triangle::vertex_1(const cartesian_point &to_set) { _vertex_1 = to_set; }
00071 
00072 void triangle::vertex_2(const cartesian_point &to_set) { _vertex_2 = to_set; }
00073 
00074 void triangle::vertex_3(const cartesian_point &to_set) { _vertex_3 = to_set; }
00075 
00076 bool triangle::inside(const cartesian_point &where) const
00077 {
00078 //cerr << "triangle::inside: not implemented" << endl << flush;
00079 if (where.x()) where.y();  // bogus.
00080   return false;
00081 }
00082 
00083 double triangle::area() const
00084 {
00085 //cerr << "triangle::area: not implemented" << endl << flush;
00086   return 5;
00087 }
00088 
00089 } // namespace.
00090 
00091 /*
00092 //temp
00093 #include "warper.h"
00094 using namespace geometric;
00095 typedef rectangle_warper<double> chuzzo;
00096 chuzzo beanburp = chuzzo(rectangle<double>(0, 23, 39, 1012),
00097   rectangle<double>(8, 19, 92982, -2), chuzzo::BOTTOM_RIGHT,
00098   chuzzo::TOP_LEFT);
00099 typedef rectangle_warper<double>::horizontal_component horzo;
00100 typedef rectangle_warper<double>::vertical_component verzo;
00101 int frunk() {
00102   horzo peen;
00103   beanburp.separate_horizontal(chuzzo::BOTTOM_RIGHT, peen);
00104   verzo neep;
00105   beanburp.separate_vertical(chuzzo::TOP_RIGHT, neep);
00106 }
00107 */
00108 
00109 
00110 
00111 
00112 
Generated on Sat Jan 28 04:22:42 2012 for hoople2 project by  doxygen 1.6.3