BoundingCylinder.cpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #include "BoundingCylinder.hpp"
00023 #include "BoundingBox.hpp"
00024 #include <cstdio>
00025 
00026 namespace se_core {
00027 
00028     bool BoundingCylinder
00029     ::isTouching(const BoundingBox& b) const {
00030         if(b.maxY_ < minY_
00031                || b.minY_ > maxY_
00032                || maxY_ < b.minY_
00033                || minY_ > b.maxY_)
00034             return false;
00035 
00036         if(b.maxX_ + radius_ < centerX_
00037                || b.minX_ - radius_ > centerX_)
00038             return false;
00039 
00040         if(b.maxZ_ + radius_ < centerZ_
00041                || b.minZ_ - radius_ > centerZ_)
00042             return false;
00043         return true;
00044     }
00045 
00046 
00047     BoundingCylinder
00048     ::BoundingCylinder(const Point3& p, const BoundingBox& b)
00049         : centerX_(p.x_ + CoorT::half(b.minX_ + b.maxX_))
00050         , centerZ_(p.z_ + CoorT::half(b.minZ_ + b.maxZ_))
00051         , minY_(p.y_ + b.minY_), maxY_(p.y_ + b.maxY_)
00052         , radius_(b.smallRadius()) {
00053     }
00054 
00055 
00056     se_err::Log& operator<< (se_err::Log& log, const BoundingCylinder& b) {
00057         sprintf(log.tmp(), " BoundingCylinder{centre(%f,%f),radius(%f),y(%f,%f)}",
00058             b.centerX_, b.centerZ_, b.radius_, b.minY_,
00059             b.maxY_
00060         );
00061         log.copy(log.tmp());
00062         return log;
00063     }
00064 
00065 }
00066 

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:12 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo