| 1 | /* | 
|---|
| 2 | * Project: MoleCuilder | 
|---|
| 3 | * Description: creates and alters molecular systems | 
|---|
| 4 | * Copyright (C)  2010-2012 University of Bonn. All rights reserved. | 
|---|
| 5 | * | 
|---|
| 6 | * | 
|---|
| 7 | *   This file is part of MoleCuilder. | 
|---|
| 8 | * | 
|---|
| 9 | *    MoleCuilder is free software: you can redistribute it and/or modify | 
|---|
| 10 | *    it under the terms of the GNU General Public License as published by | 
|---|
| 11 | *    the Free Software Foundation, either version 2 of the License, or | 
|---|
| 12 | *    (at your option) any later version. | 
|---|
| 13 | * | 
|---|
| 14 | *    MoleCuilder is distributed in the hope that it will be useful, | 
|---|
| 15 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 16 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 17 | *    GNU General Public License for more details. | 
|---|
| 18 | * | 
|---|
| 19 | *    You should have received a copy of the GNU General Public License | 
|---|
| 20 | *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| 21 | */ | 
|---|
| 22 |  | 
|---|
| 23 | /* | 
|---|
| 24 | * LinePoint.cpp | 
|---|
| 25 | * | 
|---|
| 26 | *  Created on: Jan 28, 2012 | 
|---|
| 27 | *      Author: crueger | 
|---|
| 28 | */ | 
|---|
| 29 |  | 
|---|
| 30 | // include config.h | 
|---|
| 31 | #ifdef HAVE_CONFIG_H | 
|---|
| 32 | #include <config.h> | 
|---|
| 33 | #endif | 
|---|
| 34 |  | 
|---|
| 35 | //#include "CodePatterns/MemDebug.hpp" | 
|---|
| 36 |  | 
|---|
| 37 | #include "LinePoint.hpp" | 
|---|
| 38 |  | 
|---|
| 39 | #include <limits> | 
|---|
| 40 |  | 
|---|
| 41 | #include "CodePatterns/Assert.hpp" | 
|---|
| 42 | #include "defs.hpp" | 
|---|
| 43 | #include "Line.hpp" | 
|---|
| 44 | #include "Vector.hpp" | 
|---|
| 45 |  | 
|---|
| 46 | LinePoint::LinePoint(const LinePoint &src) : | 
|---|
| 47 | line(src.line),param(src.param) | 
|---|
| 48 | {} | 
|---|
| 49 |  | 
|---|
| 50 | LinePoint::LinePoint(const Line &_line, double _param) : | 
|---|
| 51 | line(_line),param(_param) | 
|---|
| 52 | {} | 
|---|
| 53 |  | 
|---|
| 54 | LinePoint& LinePoint::operator=(const LinePoint &src){ | 
|---|
| 55 | line=src.line; | 
|---|
| 56 | param=src.param; | 
|---|
| 57 | return *this; | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | Vector LinePoint::getPoint() const{ | 
|---|
| 61 | ASSERT(!isInfinite(),"getPoint() on infinite LinePoint called"); | 
|---|
| 62 | return (*line.origin)+param*(*line.direction); | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 | Line LinePoint::getLine() const{ | 
|---|
| 66 | return line; | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | bool LinePoint::isInfinite() const{ | 
|---|
| 70 | return isPosInfinity() || isNegInfinity(); | 
|---|
| 71 | } | 
|---|
| 72 | bool LinePoint::isPosInfinity() const{ | 
|---|
| 73 | return param == std::numeric_limits<double>::infinity(); | 
|---|
| 74 | } | 
|---|
| 75 | bool LinePoint::isNegInfinity() const{ | 
|---|
| 76 | return param == -std::numeric_limits<double>::infinity(); | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | bool operator==(const LinePoint &x, const LinePoint &y){ | 
|---|
| 80 | ASSERT(x.line==y.line,"Operation on two points of different lines"); | 
|---|
| 81 | return x.param == y.param; | 
|---|
| 82 |  | 
|---|
| 83 | } | 
|---|
| 84 | bool operator<(const LinePoint &x, const LinePoint &y){ | 
|---|
| 85 | ASSERT(x.line==y.line,"Operation on two points of different lines"); | 
|---|
| 86 | return x.param<y.param; | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|