Filter a list of points according to one coordinate

Rulatir shared this question 2 years ago

HAVE: a list l1 of 3D points, e.g. {(5,7,3),(9,2,19),(54,43,0),(21,-43,1),(33,142857,0)}

WANT: a list of those points from l1 whose z coordinates equal 0, i.e. {(54,43,0),(33,142857,0)}

How do I?

For those who will insist on "what are you really trying to do": the z values are computed as a function of x and y values, and the function is non-invertible, so it is not realistically possible to compute its zeros within a rectangle without an exhaustive search and filtering to keep the zeros.

Since I'm working with integer points, it might be possible to encode each (x,y) coordinate pair as a single integer x*W+y, decode it in the KeepIf condition, and compute the function there, but that's extremely roundabout and I would like to avoid doing that.

1

KeepIf(z(P)==0,P,l1)
isn't enough?

When we ask the context, it's always to help to get a better answer. Nothing more, nothing less.

1

Yes, KeepIf(z(P)==0,P,l1) works. I got confused by some wording in the docs regarding cases when arbitrary conditions can be used vs. cases when only `==` or `!=` can be used.

As for the context question, no, it's not always asked for that reason. In my experience, more often than not it is asked as a matter of pure pedantic principle. At least one GeoGebra developer active in this forum routinely withholds answers he already knows until the person asking the question completes the "what are you trying to do" ritual that usually takes two or more extra rounds of communication.

1

If you can't refrain from personal attacks you will be banned. Keep your posts polite and professional