Approach to check if the point is inside the grid

Hi all,

I am trying to check if the point is inside the grid using grasshopper. My approach is to draw a line between the point and the grid to find out the closest one but this approach will have a problem that the point might not be inside that grid, as shown in the below figure.
May I have your suggestions on this problem?

Problem occurred:

Ideal output:

question box.3dm (39.8 KB)
question.gh (10.9 KB)

Thank you in advance,
-HC

You could try this:
question-b.gh (6.4 KB)

1 Like

Or you’re using the Point in Curve component to check in which box you are.

answer.gh (16.1 KB)

1 Like

Or even like this:

2021-10-20 08-37-42.2021-10-20 08_38_56

answer3.gh (12.7 KB)

2 Likes

Thanks all :slight_smile: !

2 Likes

In your case you could also do it by math:


question_Re.gh (25.4 KB)

2 Likes

@akilli @Baris @martinsiegrist @diff-arch

I would like to ask a follow-up question, is there any possible method to assign each grid a customized value? My idea is to assign value to the center point of the grid, but is it possible to do it in grasshopper? (Elefront is good but it is required to bake the geometry first, wondering if there are any other approaches.)

-HC

The least restricted and easiest to change method would be to place a Text Dot into every square in Rhino. That way you can just move the dots around with the mouse.

1 Like

Create a multiline text panel with the 25 numbers you wish. Then use the area component to get the 25 centroids of the grids (25 grids, 25 centroids). Then use text tag to visualize the 25 numbers at the location of the 25 centroids.

@martinsiegrist @iason.bournas

Thanks all, but I want to use the customized value for subsequent calculation in grasshopper. Wondering if it is possible to do this.

If you know which of the 25 grids you want to select, let’s say grid 17, then you also know the number that corresponds to it. That is true if you have your 25 grids aligned with the 25 numbersexample_simple.gh (8.6 KB)

You could use Elefront to bake a grid of dots. Then manually assign values to each dot and reference the dots in Grasshopper again.

dots.gh (11.6 KB)

1 Like

And here is one example were the numbering of the grids can be randomexample_custom_number.gh (13.2 KB)

1 Like

Seems that it has to bake it first then enter the value in Rhino rather than Grasshopper, then read it in Grasshopper again for following process. Otherwise, will need to maintain the data carefully in grasshopper for processing

thanks!

It all depends on how efficiently you want to be able to manipulate or relocate values.

yes. Let me give an attempt on this