07-05-2014, 02:43 PM
Post: #1
 slawek39 Member Posts: 74 Joined: Jun 2014
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)
07-09-2014, 07:23 PM
Post: #2
 Eddie W. Shore Senior Member Posts: 1,223 Joined: Dec 2013
I don't know how TRIANGLE is used in every form, but here is the basic form of TRIANGLE:

TRIANGLE(x1, y1, x2, y2, x3, y3, color 1, color 2*, color 3*)

If only color 1 is included, the triangle will be a solid color. If the 3 colors are included, we get a triangle of blended colors. The syntax is the same for both TRIANGLE and TRIANGLE_P.

Eddie
09-15-2014, 03:26 AM (This post was last modified: 09-15-2014 03:22 PM by Han.)
Post: #3
 Han Senior Member Posts: 1,878 Joined: Dec 2013
(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
 « Next Oldest | Next Newest »

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