Skip to content

Commit

Permalink
opns cga example added
Browse files Browse the repository at this point in the history
  • Loading branch information
enkimute committed Nov 7, 2018
1 parent 9ee4700 commit f77ac8e
Show file tree
Hide file tree
Showing 3 changed files with 40 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 @@ -184,7 +184,7 @@ <H3 STYLE="flex-grow:1" ID="title">The CoffeeShop</H3>
"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",
"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_points_circles_lines","cga3d_points_spheres_planes","cga3d_dual_spheres_planes","cga3d_intersections","cga3d_project_reject","cga3d_opns_line_circle",
"mga3d_points_and_lines",
"ccga3d_points_quadrics",
"qcga3d_points_and_more",
Expand Down
39 changes: 39 additions & 0 deletions examples/example_cga3d_opns_line_circle.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<HEAD>
<SCRIPT SRC="../ganja.js"></SCRIPT>
</HEAD>
<BODY><SCRIPT>
// the OPNS visualizer can be used to visualize degenerate elements
// for which the parametric form is unknown. It works by raytracing
// a boundary on the length of the outer product.

// We demonstrate in CGA. The OPNS visualizer only works for the graded
// algebra generator, so we have to specify that when we create our algebra :
Algebra({p:4,q:1,graded:true},()=>{

// As usual, we start by defining a null basis, and upcasting for points
var ni = 1e4+1e5, no = .5e5-.5e4, nino = ni^no;
var up = (x)=> no + x + .5*x*x*ni;

// for OPNS viz we also need an "up" version that uses only basis blades :
var upviz = ["x","y","z",".5*(x*x+y*y+z*z)-.5",".5*(x*x+y*y+z*z)+.5"];

// Next we create some points
var p1 = up(1e3-1e1), p2 = up(-1e3-1e1), p3 = up(1e2-1e1),
q1 = up(1e1+1e2), q2 = up(1e1-1e2);

// We create a circle and a line.
var c1 = (p1^p2^p3).Normalized, c2 = (p3^p2^ni).Normalized;

// Now we will use the OPNS visualizer to show how the shape of the
// object evolves as we interpolate from one to the other.
document.body.appendChild(this.graphGL2(()=>{
// factor between 0 and 1
var t = Math.min(1,Math.max(0,0.5 + 0.75*Math.sin(performance.now()/700)));
// interpolate
var i = c1*t+(1-t)*c2;
// graph in pretty blue.
return [0x0088FF,i]
},{up:upviz, animate:1}))

})
</SCRIPT></BODY>
Binary file added images/cga3d_opns_line_circle.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 f77ac8e

Please sign in to comment.