22 #include "gfx/gfx_mesh.h"
24 namespace vsr{
namespace cga {
32 static inline Mesh
Torus(
double rad = 1.0,
int slices =20,
int stacks=20){
38 for (
int j = 0; j < slices; ++j){
39 VSR_PRECISION tu = PI * (VSR_PRECISION)j/slices;
40 Pnt pa = Round::pnt_cir(cirb, tu);
41 for (
int i = 0; i < stacks; ++i){
42 VSR_PRECISION tv = PI * (VSR_PRECISION)i/stacks;
43 Pnt pb = Round::pnt_cir( (pa <= cira).dual(), tv );
51 for (
int j = 0; j < slices; ++j){
52 static bool color =
false;
54 for (
int i = 0; i < stacks; ++i){
55 int a = j * stacks + i;
56 int b = (j < slices - 1) ? a + stacks : i;
57 int c = (i < stacks - 1 ) ? a + 1 : j * stacks;
58 int d = (j < slices - 1 ) ? c + stacks : ( i < stacks -1 ) ? i + 1 : 0 ;
60 m[a].Col.set(color,!color,1,1);
61 m[b].Col.set(color,!color,1,1);
62 m[c].Col.set(color,!color,1,1);
63 m[d].Col.set(color,!color,1,1);
64 m.add(a).add(b).add(c).add(d);
76 static inline Mesh
Skin( T cir,
int num,
int res = 10){
80 for (
int i = 0; i < res; ++i){
81 double t= 1.0 * i/res;
83 for (
int j = 0; j < num; ++j){
84 Vec v = Round::pnt_cir( cir[j], TWOPI * t );
85 m.add( v[0], v[1], v[2] );
91 for (
int i = 0; i < num-1; ++i){
92 for (
int j = 0; j < res; ++j){
107 m.add(i).add(i+1+num);
111 for (
int i = 0; i < res; ++i){
112 for (
int j = 0; j < num-1; ++j){
124 Vec3f ta = m[b].Pos - m[a].Pos;
125 Vec3f tb = m[d].Pos - m[a].Pos;
126 Vec3f tc = -ta.cross(tb);
127 m[a].Norm = tc.unit();
Common Operations Specific to CGA3D.
Generic Geometric Number Types (templated on an algebra and a basis )
Definition: vsr_algebra.h:69
#define CXZ(f)
A vsr::cga::Circle in xz plane with radius f.
Definition: vsr_cga3D_op.h:624
static Mesh Skin(T cir, int num, int res=10)
Skin Circles – pass in an array or vector of circles.
Definition: vsr_shapes.h:76
Definition: vsr_shapes.h:29
the versor library namespace
Definition: vsr_algebra.h:29
static Mesh Torus(double rad=1.0, int slices=20, int stacks=20)
A Torus Mesh.
Definition: vsr_shapes.h:32