File indexing completed on 2024-04-14 03:42:33

0001 #ifndef _SpatialConstraint_h
0002 #define _SpatialConstraint_h
0003 //#     Filename:       SpatialConstraint.h
0004 //#
0005 //#     Classes defined here: SpatialConstraint SpatialSign
0006 //#
0007 //#
0008 //#     Author:         Peter Z. Kunszt, based on A. Szalay's code
0009 //#
0010 //#     Date:           October 16, 1998
0011 //#
0012 //#     SPDX-FileCopyrightText: 2000 Peter Z. Kunszt Alex S. Szalay, Aniruddha R. Thakar
0013 //#                     The Johns Hopkins University
0014 //#
0015 //#     Modification History:
0016 //#
0017 //#     Oct 18, 2001 : Dennis C. Dinge -- Replaced ValVec with std::vector
0018 //#
0019 
0020 #include "SpatialGeneral.h"
0021 #include "SpatialSign.h"
0022 #include "SpatialVector.h"
0023 //
0024 //########################################################################
0025 //#
0026 //# Spatial Constraint class
0027 //#
0028 /**
0029    The Constraint is really a cone on the sky-sphere. It is characterized
0030    by its direction a_, the opening angle s_ and its cosine -- the distance
0031    of the plane intersecting the sphere and the sphere center.
0032    If d_ = 0, we have a half-sphere. If it is negative, we have a 'hole'
0033    i.e. the room angle is larger than 90degrees.
0034 
0035    Example: positive distance
0036 
0037                    ____
0038                 ---    ---
0039                /        /|\
0040               /        / |=\
0041              |        /  |==|     this side is in the convex.
0042             |        /\s |===|
0043             |------------|---| -> direction a
0044             |        \   |===|
0045              |        \  |==|
0046               \        \ |=/
0047                \        \|/
0048                 ---____---
0049 
0050 
0051                      <-d-> is positive (s < 90)
0052 
0053  Example: negative distance
0054 
0055                       ____
0056                    ---====---
0057      this side is /========/|\
0058      in the      /========/=| \
0059      convex     |==== s__/==|  |
0060                |===== / /===|   |
0061      dir. a <- |------------|---|  'hole' in the sphere
0062                |========\===|   |
0063                 |========\==|  |
0064                  \========\=| /
0065                   \========\|/
0066                    ---____---
0067 
0068 
0069                         <-d-> is negative (s > 90)
0070 
0071  for d=0 we have a half-sphere. Combining such, we get triangles, rectangles
0072  etc on the sphere surface (pure ZERO convexes)
0073 
0074 */
0075 class LINKAGE SpatialConstraint
0076 {
0077   public:
0078     /// Constructor
0079     SpatialConstraint(){};
0080 
0081     /// Initialization constructor
0082     SpatialConstraint(SpatialVector, float64);
0083 
0084     /// check whether a vector is inside this
0085     bool contains(const SpatialVector v);
0086 
0087     /// give back vector
0088     SpatialVector &v() { return a_; }
0089 
0090   private:
0091     Sign sign_;
0092     SpatialVector a_; // normal vector
0093     float64 d_;       // distance from origin
0094     float64 s_;       // cone angle in radians
0095 
0096     friend class RangeConvex;
0097 };
0098 
0099 #endif