frankiezafe.net & org . LABO . projection on plane (better)
Array
08.07.14

back to bascis
in this sketch, i go back to basics of 3D geometry:

  1. how to describe a plane using one 3D point and a normal vector
  2. how to get 2 other vectors ( U & V ), perpendicular to the normal and representing the local X and Y axis of the plane
    (the last image, with the triangle grid, shows the result of defining a list of points in UV and render them onto the plane)
  3. how to project points on this plane, get the new 3D coordinates and transform it into a local coordinate (uv) of the plane
  4. how to sort the projected points in order to draw a shape with them
  5. and a little smoothing

download the processing sketch here 
(it was too difficult to put it on openprocessing: i need java object to sort the points, and the applet maker is only accepting JAVA2D rendering mode + my processing 1.5 is not running anymore...)

magic code of the plane:

  public Plane( float x, float y, float z ) {
    normale = new PVector( 1,1,1 );
    normale.normalize();
    xyz = new PVector( x, y, z );
    u = new PVector();
    v = new PVector();
    render();
    viewrot = new PVector();
    update();
  }
  
  private void render() {
    normale.normalize();
    u = normale.cross( UP );
    u.normalize();
    v = normale.cross( u );
    v.normalize();
    d = -normale.x * xyz.x -normale.y * xyz.y -normale.z * xyz.z;
  }