This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

anar+

by   LaBelle + Nembrini
©2008

built with ( )
   examples index
Rotate: middle click or key[1]
Zoom in|out: wheel button or key[2]
AutoRotate: key[5]
(First Click inside the applet to enable keys)

This applet use OpenGL, you might have to install extra jogl libraries once to view this applet. You may have a look at image capture and video at the bottom of this page. You might accept security security permenently to remove the security prompts on each pages.



sourcecode


   PDE Download:   Test00wDSimpleScale.pde
   JAVA Download:   Test00wDSimpleScale.java


Click on anar+ terms to get the documentation.

import processing.opengl.*;
import anar.*;
 
 
 
 
 
 
/*
 * Example for Anar library by Guillaume LaBelle + Julien Nembrini
 * http://anar.ch
 */
 
 
 
 
Obj   result;
 
Param value;
 
 
void setup(){
 
    size(1000,500,OPENGL);
  Anar.init(this);
 
  Anar.drawAxis(true);
 
  initForm();
 
}
 
 
void initForm(){
 
  result = new Obj();
 
  // ///////////////////////
 
  // three random points
  Pt pA = Anar.PtRnd(100,100,100);
  Pt pB = Anar.PtRnd(100,100,100);
  Pt pC = Anar.PtRnd(100,100,100);
 
  // create a rectangular basis to construct an orthogonal box
  Pt p1 = pA;
  Pt p2 = pB;
  Pt p3 = new PtCross((Pt)pA.minus(pB),(Pt)pA.minus(pC));
  float div = 100f;
  p3.scale(1/div,1/div,1/div);
  p3.translate(pA);
 
  Pt p4 = (Pt) ((Pt)p1.minus(p2)).plus((Pt)p1.minus(p3)).plus(p1);
 
  Face f = new Face();
  f.add(p1);
  f.add(p2);
  f.add(p4);
  f.add(p3);
 
  Pt extrude = new PtCross((Pt)p1.minus(p2),(Pt)p1.minus(p3));
  int m = 10;
  if(extrude.length()>0)
    extrude.scale(m/extrude.length(),m/extrude.length(),m/extrude.length());
 
  Obj box = new Extrude(f,extrude);
  box.fill(255,0,0);
  result.add(box);
 
  result.add(p4);
 
  // ///////////////////////
 
  value = new Param(1);
  Param un = new Param(1);
 
  float rnd = random(1);
 
  Scale scale = new Scale(un,un,un);
 
  if(rnd<.33f)
    scale = new Scale(value,un,un);
  else
    if(rnd<.33f)
      scale = new Scale(un,value,un);
    else
      scale = new Scale(un,un,value);
 
  // ///////////////////////
 
  // here p1,p2,p3 must be orthogonal to each other!!!
  Transform frame = new Transform(p1,p2,p3,scale);
  // Transform frame = new Transform(p1,p2,scale);
  result.apply(frame);
 
}
 
 
void draw(){
  background(230);
  value.set(1+sin(frameCount/10f));
  result.draw();
 
}
 
void keyPressed(){
  if(key==' ')
    initForm();
}
 
 
 
 



screenshots