Skip to content

Commit

Permalink
added motor orbit rendering example.
Browse files Browse the repository at this point in the history
  • Loading branch information
enkimute committed Mar 27, 2019
1 parent e93517f commit 0ef912a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/coffeeshop.html
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ <H3 STYLE="flex-grow:1" ID="title">The CoffeeShop</H3>
"timespace_lorentz",
"ga3d_rotor_estimation",
"pga2d_points_and_lines","pga2d_distances_and_angles","pga2d_project_and_reject","pga2d_rotors_and_translators","pga2d_isometries", "pga2d_inverse_kinematics","pga2d_separating_axis","pga2d_pose_estimation","pga2d_euler_line","pga2d_desargues_theorem","pga2d_differentiation","pga2d_physics_moon","pga2d_origami", "pga2d_poncelet",
"pga3d_points_and_lines","pga3d_distances_and_angles","pga3d_rotors_and_translators","pga3d_icosahedron","pga3d_sampling","pga3d_slicing","pga3d_differentiation","pga3d_skinning","pga3d_physics_planets","pga3d_origami","pga3d_physics_symmetric_top","pga3d_physics_free_top","pga3d_objects","pga3d_levenberg_marquardt",
"pga3d_points_and_lines","pga3d_distances_and_angles","pga3d_rotors_and_translators","pga3d_icosahedron","pga3d_sampling","pga3d_slicing","pga3d_differentiation","pga3d_skinning","pga3d_physics_planets","pga3d_origami","pga3d_physics_symmetric_top","pga3d_physics_free_top","pga3d_objects","pga3d_levenberg_marquardt","pga3d_motor_orbits",
"cga2d_points_and_circles","cga2d_project_and_reject","cga2d_rotors_and_translators","cga2d_euler_line",
"cga3d_points_circles_lines","cga3d_points_spheres_planes","cga3d_dual_spheres_planes","cga3d_intersections","cga3d_project_reject","cga3d_opns_visualizer","cga3d_opns_line_circle","cga3d_json",
"mga3d_points_and_lines",
Expand Down
49 changes: 49 additions & 0 deletions examples/example_pga3d_motor_orbits.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<HEAD>
<SCRIPT SRC="../ganja.js"></SCRIPT>
</HEAD>
<BODY><SCRIPT>
Algebra(3,0,1,()=>{

// Ganja.js can graph the orbits of parametrised motor variables :
// these are functions that take one parameter 0<x<1 and return a motor.
// For a function of 1 parameter, the orbit is rendered as a curve.

var circle = (BV,r)=>x=>Math.E**(Math.PI*x*BV)*(1+r*.5e01),
segment = (BV)=>x=>1+x*0.5*BV;

// The product of two such parametrised 1D orbits is a 2D manifold :
// In ganja, you can simply multiply the two 1-parameter orbits to
// make a 2-parameter manifold. (rendered as a sheet)

// this allows us to multiply two circles into a torus or sphere,
// two segments into a plane, or a segment and a circle to produce
// a disk, cone or cylinder.

var torus = (r1,r2)=>circle(1e12,r1)*circle(1e13,r2),
sphere = (r)=>circle(1e13,0)*circle(1e12,r),
plane = (x,y)=>segment(x*1e02)*segment(y*1e03),
cylinder = (r,l)=>segment(l*1e02)*circle(1e13,r),
disk = (r)=>circle(1e12,0)*segment(r*1e01),
cone = (r,l)=>circle(1e12,0)*segment(r*1e01-l*1e03);

// we can render these now just as our other primitives ..
var elements = [
0xff0000, circle(1e12,1),
0x0000ff, segment(1e01),
0xff0088, torus(.5,.2),
0xffff00, sphere(0.1),
0x00ffff, plane(0.2,0.2),
0x8800ff, cylinder(.05,1),
0x00ff00, disk(0.2),
0xffffff, cone(0.1,0.2)
];

// show with rotating camera..
var camera=0e1+1;
document.body.appendChild(this.graph(()=>{
var t=performance.now()/1234;
camera.set( Math.cos(t) + Math.sin(t)*1e13 );
return elements;
},{camera,gl:1,animate:1}));

})</SCRIPT></BODY>
Binary file added images/pga3d_motor_orbits.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0ef912a

Please sign in to comment.