Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:43

0001 #pragma once
0002 
0003 #include "SPlaceSphere.h"
0004 #include "SPlaceCylinder.h"
0005 #include "SPlaceCircle.h"
0006 
0007 
0008 struct SPlace
0009 {
0010     static constexpr const char* OPTS = "TR,tr,R,T,r,t" ; 
0011     static NP* AroundSphere(   const char* opts, double radius, double item_arclen, unsigned num_ring=10 ); 
0012     static NP* AroundCylinder( const char* opts, double radius, double halfheight , unsigned num_ring=10, unsigned num_in_ring=16  ); 
0013     static NP* AroundCircle(   const char* opts, double radius, unsigned numInRing=4, double fracPhase=0. ); 
0014 };
0015 
0016 
0017 /**
0018 SPlace::AroundSphere
0019 -----------------------
0020 
0021 The number within each ring at a particular z is determined 
0022 from the circumference the ring at that z. 
0023 
0024 
0025 
0026 
0027 
0028             +---+            
0029         +------------+
0030       +----------------+
0031         +------------+
0032             +---+            
0033 
0034 
0035      x = r sin th cos ph
0036      y = r sin th sin ph       x^2 + y^2 = r^2 sin^2 th
0037      z = r cos th                    z^2 = r^2 cos^2 th
0038               
0039     cos th = z/r 
0040     sin th = sqrt( 1 - (z/r)^2 )
0041 
0042 
0043                r sin th
0044          +. .+. .+
0045           \  |  /|
0046            \ | / | r cos th
0047             \|/  |
0048    ---+------+---+---+ 
0049                  r
0050 
0051 
0052 Circumference of ring : 2*pi*(r*sin th) = 2*pi*r*sqrt(1 - (z/r)^2 )     
0053 at z=0 -> 2*pi*r at z =r  -> 0  
0054 
0055 **/
0056 
0057 
0058 NP* SPlace::AroundSphere(const char* opts_, double radius, double item_arclen, unsigned num_ring )
0059 {
0060     const char* opts = opts_ ? opts_ : OPTS ; 
0061     SPlaceSphere sp(radius, item_arclen, num_ring); 
0062     return sp.transforms(opts)  ; 
0063 }
0064 
0065 
0066 /**
0067 SPlace::AroundCylinder
0068 ------------------------
0069 
0070 Form placement transforms that orient local-Z axis to 
0071 a radial outwards direction with translation at points around the cylinder.  
0072 
0073 flip:false(default)
0074     transform memory layout has last 4 of 16 elements (actually 12,13,14) 
0075     holding the translation, which corresponds to the OpenGL standard
0076 
0077 flip:true
0078     transform memory layout has translation in right hand column at elements 3,7,11
0079     this is needed by pyvista it seems 
0080     This corresponds to the transposed transform compared with flip:false
0081 
0082 **/
0083 
0084 NP* SPlace::AroundCylinder(const char* opts_, double radius, double halfheight, unsigned num_ring, unsigned num_in_ring )
0085 {
0086     const char* opts = opts_ ? opts_ : OPTS ; 
0087     SPlaceCylinder cy(radius, halfheight, num_ring, num_in_ring ); 
0088     return cy.transforms(opts)  ; 
0089 }
0090 
0091 
0092 /**
0093 SPlace::AroundCircle
0094 ---------------------
0095 
0096 Circle currently fixed in XZ plane 
0097 
0098 **/
0099 
0100 NP* SPlace::AroundCircle(const char* opts_, double radius, unsigned numInRing, double fracPhase )
0101 {
0102     const char* opts = opts_ ? opts_ : OPTS ; 
0103     SPlaceCircle ci(radius, numInRing, fracPhase ); 
0104     return ci.transforms(opts)  ; 
0105 }
0106 
0107