cancel
Showing results for 
Search instead for 
Did you mean: 
Jan_D
Level 6
305 297 32 76
Message 1 of 5
991
Flag Post

Solved!

HP Prime - Problems with TRIANGLE_P command in programs.

HP Recommended
HP Prime

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 3-dimensional 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 3-dimensional 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:

 

2016-10-13 20.55.55.jpg

 

 

 

 

 

 

 

 

 

 

This is not very spectacular because the only thing the program does is leaving the z-coordinate of the points away and drawing the resulting 2-dimensional triangle. So there is not much 3-dimensionality 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])

user manual

 

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.

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
cyrille
Level 6
Level 6
252 251 42 78
Message 4 of 5
Flag Post
HP Recommended

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

I am an HP Employee

View solution in original post

Tags (1)
Was this reply helpful? Yes No
4 REPLIES 4
Maké
Level 9
3,551 3,458 180 540
Message 2 of 5
Flag Post
HP Recommended

Hi!, @Jan_D:

 

See, if this link, serve for you ... http://edspi31415.blogspot.com.ar/2015/11/hp-prime-geometry-app-tutorial-part-8.html

 

IMG_20161015_103153.jpg

 

Kind Regards !.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
Was this reply helpful? Yes No
Jan_D
Author
Level 6
305 297 32 76
Message 3 of 5
Flag Post
HP Recommended

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.

Was this reply helpful? Yes No
cyrille
Level 6
Level 6
252 251 42 78
Message 4 of 5
Flag Post
HP Recommended

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

I am an HP Employee

View solution in original post

Tags (1)
Was this reply helpful? Yes No
Jan_D
Author
Level 6
305 297 32 76
Message 5 of 5
Flag Post
HP Recommended

@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.

 

 

 

 

 

 

 

 

Was this reply helpful? Yes No
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation