
×InformationLearn how to upgrade to Windows 11

×InformationLearn how to upgrade to Windows 11
 HP Community
 >
 Other Products
 >
 Calculators
 >
 HP Prime  Problems with TRIANGLE_P command in programs.
 Mark Topic as New
 Mark Topic as Read
 Float this Topic for Current User
 Bookmark
 Subscribe
 Mute
 Printer Friendly Page
Create an account on the HP Community to personalize your profile and ask a question
Solved!
HP Prime  Problems with TRIANGLE_P command in programs.
10142016 11:13 AM  edited 10152016 08:56 AM
I have version 2015 7 28 (8151) of the firmware and can not update it further because I have only the Android app.
Maybe the next problem has also been solved already in a more recent update, like a previous problem of mine. Let’s see.
I want to project a 3dimensional triangle on the screen by using the advanced form of TRIANGLE_P.
First the good news.
The following program works:
EXPORT experiment1 BEGIN LOCAL P1,P2,P3; RECT_P(); //clears the screen P1:={100,100,75}; P2:={200,100,75}; P3:={100,200,225}; TRIANGLE_P( {P1,P2,P3} , {{1,2,3,#FF}} ); FREEZE; END;
Explanation: I define three 3dimensional points P1,P2,P3 and insert them as a list in the triangle command. These are the corners of the triangle.
In the second argument I define the triangle by specifying the indices of these points in the first list, which are 1,2,3. #FF means it is color blue.
This is the result:
This is not very spectacular because the only thing the program does is leaving the zcoordinate of the points away and drawing the resulting 2dimensional triangle. So there is not much 3dimensionality about this. In fact nothing.
Now I am going to try to make it a little bit more complicated by entering the third argument, which I have left out so far. The first 2 arguments are the 2 lists of lists.
The simplest form is either a rotation matrix or the trivial list{1}:
Syntax: TRIANGLE_P([G],points_definition, triangle_definitions,
rotation_matrix or {rotation_matrix or 1, ["N"], [{eye_x, eye_y, eye_z}
or 1], [{3Dxmin, 3Dxmax, 3Dymin, 3Dymax, 3Dzmin, 3Dzmax}]}, [zstring])
The simplest rotation matrix is the identity matrix which consists of all zeros except the diagonal elements which are 1. So I create M1 that way.
Now I replace the triangle command by:
TRIANGLE_P( {P1,P2,P3} , {{1,2,3,#FF}},M1 );
Or
TRIANGLE_P( {P1,P2,P3} , {{1,2,3,#FF}},{1} );
Both programs return as output: ‘Error: Invalid input’.
I have tried more forms of the third argument, e.g by specifying all possible sub arguments, but whatever I try, I always get nothing else than: ‘Error: Invalid input’.
So I would like to know if whether my out of date firmware is the cause, or I do something wrong or this is a bug.
Solved! Go to Solution.
Accepted Solutions
10172016 01:39 AM
Hello,
I figured it out...
The "problem" is that with only 3 inputs in the first list and one rotation matrix, the system thinks, on first examination, that the 3 parameters are 3 points with x, y, z coordinates for each of the 3 points. On second examination, it sees that they are not valid and generates an error. This stems from the fact that Triangle can take so many different type of arguements and that it is not always easy to distinguish between the various forms.
You can make sure that the system interprets that input data as teh form that you want by making sure that the point list has at least 5 items (even if they are not used). Then it will work as in:
EXPORT tt
BEGIN
LOCAL P1,P2,P3;
RECT_P(); //clears the screen
P1:={100,100,75};
P2:={200,100,75};
P3:={100,200,225};
TRIANGLE_P( {P1,P2,P3, P1, P1} , {{1,2,3,#FF}},[[0.5,1,0,0],[0,2,0,0],[0,0,1,0],[0,0,0,0]] );
FREEZE;
END;
Cyrille
10152016 07:33 AM
Hi!, @Jan_D:
See, if this link, serve for you ... http://edspi31415.blogspot.com.ar/2015/11/hpprimegeometryapptutorialpart8.html
Have a nice day !.
@Maké (Technical Advisor Premium  HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
10152016 09:11 AM
Thank you.
But this is something completely different and has nothing to do with the geometry app.
It is a command which can be found in the menu of the Program editor via: Cmds  Drawing  Pixels  Triangle_P.
Via these Pixels  commands you have control over the color of every pixel of the screen.
Triangle_P allows a 3D transformation, which the geometry app can not do.
10172016 01:39 AM
Hello,
I figured it out...
The "problem" is that with only 3 inputs in the first list and one rotation matrix, the system thinks, on first examination, that the 3 parameters are 3 points with x, y, z coordinates for each of the 3 points. On second examination, it sees that they are not valid and generates an error. This stems from the fact that Triangle can take so many different type of arguements and that it is not always easy to distinguish between the various forms.
You can make sure that the system interprets that input data as teh form that you want by making sure that the point list has at least 5 items (even if they are not used). Then it will work as in:
EXPORT tt
BEGIN
LOCAL P1,P2,P3;
RECT_P(); //clears the screen
P1:={100,100,75};
P2:={200,100,75};
P3:={100,200,225};
TRIANGLE_P( {P1,P2,P3, P1, P1} , {{1,2,3,#FF}},[[0.5,1,0,0],[0,2,0,0],[0,0,1,0],[0,0,0,0]] );
FREEZE;
END;
Cyrille
10172016 05:27 AM  edited 10172016 05:33 AM
@cyrille wrote:Hello,
I figured it out...
Thank you very much. This helps. Good work!
I am trying to understand what is going on.
I think you mean that the system confuses my intention with this version of the command:
Syntax: TRIANGLE_P([G], {x1, y1, [c1], [z1]}, {x2, y2, [c2], [z2]},{x3, y3,
[c3], [z3]}, ["ZString"])
So it confuses P1,P2 and P3 with the x1, y1 and c1 of the first point. Which can not be so because P1, P2 and P3 are lists. But OK, this is imaginable.
Subsequently it seems to confuse {{1,2,3,#FF}} with the coordinates of the second point: {x2, y2, [c2], [z2]}.
But this is impossible because I have used double curly brackets.
At last it seems to think that the rotation matrix should actually be the coordinates of the third point. Of course that would be reason enough to report a message of invalid input.
I arrive at the conclusion that this is a bug.
But there is a way out, which is often the case with this calculator.

EnglishOpen Menu
Didn't find what you were looking for? Ask the community