Post Reply 
Advanced form of TRIANGLE_P
09-15-2014, 03:26 AM (This post was last modified: 09-15-2014 03:22 PM by Han.)
Post: #3
RE: Advanced form of TRIANGLE_P
(07-05-2014 02:43 PM)slawek39 Wrote:  Is anyone able to write a simple example of the use of advanced forms of TRIANGLE_P? I do not know how to draw a single triangle with the advanced form.
Software version (6030)

Edit: Caveat emptor -- I have only tested one variation of the advanced form. You can see an example of it here: http://www.hpmuseum.org/forum/thread-95.html

Code:
triangle_p(
  G0,
  pointdef,
  triangledef,
  {
     RotMatrix,
     "N",
     {xeye,yeye,zeye},
     {xmin3D,xmax3D,ymin3D,ymax3D,zmin3D,zmax3D}
  },
  zclip
);

G0: can be replaced with G1 through G9 (these are the graphics buffers; G0 is the current display)

pointdef: a list of point definitions. A point definition is either a list or a vector of the following form:
  • {x,y,z,color} for 3-dimensional point with color
  • [x,y,z,color] same as above, but vector form
  • {(x,y), color} for 2-dimensional point with color
  • (x,y) same as above but no color (default black)
The color is optional. Where there may be ambiguity (e.g. {x,y,z} with no color vs {x,y,color} I _think_ the underlying algorithm looks for whether there are other arguments that implicitly mean 3D point and not 2D point -- such as the rotation matrix. The point definitions can be a mix of forms, but don't mix 2D and 3D points.

triangledef: a list of triangle definitions. A triangle definition is a list of three integers with optional fourth (color) and fifth (alpha) elements. The first three integers refer to the index of a point specified in pointdef.
  • {n1, n2, n3, color, alpha}
  • {n1, n2, n3, color}
  • {n1, n2, n3}
Alpha is a value from 0 to 255. Suppose pointdef is a list of points corresponding to the corners of a square: {(0,0), (1,0), (1,1), (0,1) }. Then a triangle definition such as { {1,2,3}, {3,4,1} } will draw two triangles with corners at (0,0), (1,0), (1,1) and (1,1), (0,1), (0,0).

RotMatrix is a rotation matrix whose dimension depends on whether you use 2D or 3D points (mainly useful for 3D with perspective projection).

"N" specifies whether or not the points are normalized

{xeye,yeye,zeye} is the eyepoint location if using 3D points. While the command does not complain about improper eyepoints, users should ensure that the eyepoint lies outside of the viewing box. Otherwise, the projection may appear skewed (or possibly inverted).

{xmin3D,xmax3D,...,zmax3D} is a list specifying the corners of the viewbox. Any points outside of this viewbox is "clipped" and edges and faces are interpolated as appropriate.

zclip is a string (usually generated by a simple zclip:=triangle() command with no arguments) is used for z-clipping.

1. Don't combine alpha blending with z-clipping.
2. There is currently some misbehavior with using triangle() and line() (and the _p variants thereof) without saving the output. These commands return a string that represents the point definitions in an internal format that can be used for later calls to triangle() and/or line(). This can be achieved by simply declaring a temporary local variable, say t, and using t:=triangle( ... arguments ... );

Han

(Sorry for such a late response; just now catching up on older posts that I missed over the summer)

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Advanced form of TRIANGLE_P - slawek39 - 07-05-2014, 02:43 PM
RE: Advanced form of TRIANGLE_P - Han - 09-15-2014 03:26 AM



User(s) browsing this thread: 1 Guest(s)