1
$\begingroup$

List is an array of dimensions {61777, 3}. dist1 & dist2 are RegionDistanceFunctions.

Using:

list2 = Union[
DeleteCases[listhex, {a_, b_, c_} /;dist1[{a, b}] < 0.004 ||dist2[{a, b}] < 0.004],
Cases[listhex, {a_, b_, c_} :> {a, b, 0} /;dist1[{a, b}] < 0.004 || dist2[{a, b}] < 0.004]
]

Works fine, I delete points near the region I want and then put them back as {x,y,0}.

Now I create two RotationTransforms:

R1 = RotationTransform[120/180*\[Pi], {0, 0, 1}];
R2 = RotationTransform[120/180*2 \[Pi], {0, 0, 1}];

I wanted to do the same thing by simply applying the transformation after the condition of dist1 & dist2 is used.

list3 = Union[
   DeleteCases[listhex, {a_, b_, c_} /;dist1[{a, b}] < 0.004 || dist2[{a,b}] < 0.004], 
   DeleteCases[list, {a_, b_, c_} :> R1[{a, b, c}] /; dist1[{a, b}] <0.004 || dist2[{a, b}] < 0.004],
   DeleteCases[list, {a_, b_, c_} :> R2[{a, b, c}] /; dist1[{a, b}] < 0.004 || dist2[{a, b}] < 0.004],
   Cases[listhex, {a_, b_, c_} :> {a, b, 0} /;dist1[{a, b}] < 0.004 || dist2[{a, b}] < 0.004], 
   Cases[listhex, {a_, b_, c_} :> R1[{a, b, 0}] /; dist1[{a, b}] < 0.004|| dist2[{a, b}] < 0.004],
   Cases[listhex, {a_, b_, c_} :> R2[{a, b, 0}] /; dist1[{a, b}] < 0.004 || dist2[{a, b}] < 0.004]
   ]

Now the part using Cases works fine, it gives the same points near the region only rotated by R1 or R2. However,DeleteCases doesnt work with R1 or R2.

Dimensions[DeleteCases[list, {a_, b_, c_} /; dist1[{a, b}] < 0.004 ||dist2[{a, b}] < 0.004]]
Dimensions[DeleteCases[list, {a_, b_, c_} :> R1[{a, b, c}] /; dist1[{a, b}] < 0.004 || dist2[{a, b}] < 0.004]]
Dimensions[DeleteCases[list, {a_, b_, c_} :> R2[{a, b, c}] /; dist1[{a, b}] < 0.004 || dist2[{a, b}] < 0.004]]

{61153, 3}
{61777, 3}
{61777, 3}

Why does this happen? I can delete the cases without the rotation but using the rotation does nothing, as you can see by the dimmensions of the array. What am I missing?

$\endgroup$
  • 1
    $\begingroup$ I don't understand what the rule in DeleteCases should do: DeleteCases[list, {a_, b_, c_} :> R1[{a, b, c}]. There is no such syntax for DeleteCases, it just deletes what it finds, it doesn't replace it. $\endgroup$ – MarcoB Aug 2 '17 at 17:10
  • $\begingroup$ What I wanted to do was use the unrotated points as a guide to identify the points, but delete the rotated ones. I thought :> would hold the expression and use it as input for deletecases. $\endgroup$ – Giovanni Baez Aug 2 '17 at 17:20
  • $\begingroup$ I see. Then perhaps something like: DeleteCases[list, {a_, b_, c_} /; With[{{ra, rb, rc} = R[{a, b, c}]}, dist1[{ra, rb}] < 0.004 || dist2[{ra, rb}] < 0.004]]? You can read ; as "such that", in a way: "Delete those points from list of the form {a, b, c}, such that, with {ra, rb, rc} being the rotated points, the distances between the latter are..." $\endgroup$ – MarcoB Aug 2 '17 at 17:23
  • $\begingroup$ Wont that use the rotated points for the distance test? I need to check for distance using the original points and then delete the rotated ones. $\endgroup$ – Giovanni Baez Aug 2 '17 at 17:38
  • $\begingroup$ Giovanni, I see what you mean now. I would still recommend against it: even though it may be possible to twist DeleteCases that way with some contortions, that's really now what it is for. It would also be inadvisable because you may not find the rotated points exactly in your list, because of slightly different rounding / numerical error between the points in the list and the points you calculated through rotation. $\endgroup$ – MarcoB Aug 2 '17 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.