2 #ifndef vsr_chain_draw_INC
3 #define vsr_chain_draw_INC
5 #include "gfx/gfx_mesh.h"
6 #include "gfx/gfx_print.h"
8 #include "vsr_cga3D_draw.h"
9 #include "form/vsr_chain.h"
26 void Draw(
const Chain& c,
bool bLoop =
false,
bool bFrame=
true,
float r=1.0,
float g=1.0,
float b=1.0,
float a=1.0){
29 for (
int i = 0; i<c.num(); ++i){
30 float t=(float)i/c.num();
31 DrawAt(c[i].z(), c[i].pos(), 1-t,0,t);
32 DrawAt(c[i].y(), c[i].pos(), 1,1,t);
33 DrawAt(c.joint(i).y() * .2, c[i].pos(), 0,1,0);
40 glBegin( bLoop ? GL_LINE_LOOP : GL_LINE_STRIP);
41 for (
int i = 0; i<c.num(); ++i){
42 float t=(float)i/c.num();
43 auto cvec = c[i].vec();
44 auto nvec = c.link(i).vec() <= Vec::y;
45 gfx::GL::vertex( cvec.begin() );
46 gfx::GL::vertex( (cvec+c[i].y()*nvec).begin() );
52 void DrawR(
const Frame& f,
float r= 1.0,
float g = 1.0,
float b = 1.0,
float a = 1.0){
54 static gfx::Mesh ma = gfx::Mesh::Cylinder( .5, 2, 30);
59 gfx::GL::translate( f.pos()[0], f.pos()[1], f.pos()[2] );
60 gfx::GL::rotate( nga::Gen::aa( rot *
Gen::rot( Biv::yz * PIOVERFOUR ) ).begin() );
61 gfx::GL::scale( f.scale() );
68 gfx::GL::translate( f.pos()[0], f.pos()[1], f.pos()[2] );
69 gfx::GL::rotate( nga::Gen::aa( rot ).begin() );
70 gfx::GL::translate( 0, f.scale() * .5, 0 );
73 gfx::GL::scale( f.scale() * .5 );
86 void DrawR(
const Chain& c,
float r= 1.0,
float g = 1.0,
float b = 1.0,
float a = 1.0){
87 for (
int i = 0; i<c.num(); ++i){
88 DrawR(c[i], r, g,b,a);
92 void DrawR_(
const Chain& c,
float r= 1.0,
float g = 1.0,
float b = 1.0,
float a = 1.0){
93 for (
int i = 0; i<c.num(); ++i){
94 Draw(c[i].cxy(), r, g,b,a);
117 void Draw(
const Prismatic& p){
124 string PrintPS(
const Frame& f,
int n,
bool bx=
true,
bool by=
true,
bool bz=
true){
125 string c = name(
"c",n);
128 auto x = f.x();
auto y = f.y();
auto z = f.z();
129 auto sx = name(
"cx",n);
auto sy = name(
"cy",n);
auto sz = name(
"cz",n);
130 os <<
"\\coordinate"<<c<<
" at "<<coord(v)<<
";"<<endl;
132 if (bx) os <<
"\\coordinate"<<sx<<
" at "<<coord(x)<<
";"<<endl;
133 if (by) os <<
"\\coordinate"<<sy<<
" at "<<coord(y)<<
";"<<endl;
134 if (bz) os <<
"\\coordinate"<<sz<<
" at "<<coord(z)<<
";"<<endl;
136 if (bx) os <<
"\\draw [->]"<<c<<
"--+"<<sx<<
";"<<endl;
137 if (by) os <<
"\\draw [->]"<<c<<
"--+"<<sy<<
";"<<endl;
138 if (bz) os <<
"\\draw [->]"<<c<<
"--+"<<sz<<
";"<<endl;
140 auto sxp = name(
"cxp",n);
auto sxn = name(
"cxn",n);
141 auto syp = name(
"cyp",n);
auto syn = name(
"cyn",n);
142 auto szp = name(
"czp",n);
auto szn = name(
"czn",n);
144 os << coord(sxp,x/4.0) << coord(sxn,-x/4.0);
145 os << coord(syp,y/4.0) << coord(syn,-y/4.0);
146 os << coord(szp,z/2.0) << coord(szn,-z/2.0);
148 os <<
"\\draw[rounded corners=4pt]"<<c<<
"+"<<sxp<<
"--+"<<syp<<
"--+"<<sxn<<
"--+"<<syn<<
"--cycle;"<<endl;
157 string PrintPS(
const Chain& c){
159 for (
int i = 0;i<c.num();++i){
160 int next = i<(c.num()-1)? i+1:0;
161 s+=PrintPS(c[i],i,
false,
false,
true);
162 s+=draw(c[i].vec(), c[next].vec(),
"-");
NVec< 5 > Vec
Vector
Definition: vsr_cga3D_types.h:62
Definition: vsr_cga2D_draw.h:13
static Rot rot(const Biv &b)
vsr::cga::Rotor from vsr::cga::Bivector
A sequence of spatial Frames.
Definition: vsr_chain.h:107
Generators and Logarithms Optimized for 3D Conformal Geometric Algebra.
Definition: vsr_cga3D_op.h:119
Orthonormal Frame composed from a Position and Orientation.
Definition: vsr_cga3D_frame.h:47
NBiv< 5 > Biv
Bivector
Definition: vsr_cga3D_types.h:63
Lin Line
Direct Line Trivector \(p_a \wedge p_b \wedge n_\infty\)
Definition: vsr_cga3D_types.h:140
Definition: vsr_chain.h:61
NRot< 5 > Rot
Rotor
Definition: vsr_cga3D_types.h:64