Grasshopper

algorithmic modeling for Rhino

I have 3 points in space which have different grey scale values(0 to 255)

I need to determine the grey value of a 4th point based on its location relative to the 3 points. The calculated grey value needs to be biased towards the value of the closest point. For example if the 4th point is coincident with point 1 then the calculated grey value should be the same as the grey value of point 1. On the other hand, if the 4th point is equidistant from the 3 points, then the grey value should simply be the average of the 3 grey values.

Many thanks.

Views: 798

Replies to This Discussion

@WT4, wow this kept me trying for a while and failing.

Doing it with 2 points is quite easy, but 3 is really hard. Now I have found a solution that at least works INSIDE the triangle, which I have found here:

http://answers.unity3d.com/questions/383804/calculate-uv-coordinate...

I have attached a recreation of that in GH. I am sure there are some math pros out there that can solve this. 

Good luck!

Attachments:
Many thanks for your help. Will try this when I get back to work tomorrow

Sounds like you need some barycentric coordinates...

Attachments:

Wow, ok that is much simpler in a way, except converting from barycentric to cartesian seems somewhat tricky looking at wikipedia.

What would be nice to have would be a "project point on brep" component. Then you could simply use the 3 reference points to create a surface and give them the greyscale value as a Z value. Then project the point to evaluate onto the resulting triangle. That points Z value will then be the value we need. Its kind of the same as the way you suggest, but without introducing a rather unusual (to me at least) coordinate system. It would also allow the point to evaluate to be moved around more easily or to be coming from something else in GH.

I have attached an approximation using a curve projected on a surface:

Attachments:

Also works with 4 points! :) Although the order of points is important so there is no overlapping.

Attachments:

Thank you your help.

However the point for which the grey value is required is not necessarily in the plane of the other 3 points.

So you mean it has to work completely 3-dimensionally? I got pretty close a few times, but in the end it never worked out. this has to be possible! I will give it another try later.

I managed to get a solution by using a linear set of equation. This involves solving 4 sets of simultaneous equations. If we have 4 points in space which are in close proximity to the target point. Then the following equation can be generated

A+Bx1+Cy1+Dz1=Colour1
A+Bx2+Cy2+Dz2=Colour2
A+Bx3+Cy3+Dz3=Colour3
A+Bx4+Cy4+Dz4=Colour4

Where X1, y1, z1 are coordinates of the 1st point etc
and Colour1 is the grey scale number for the 1st point.
A, B, C and D are constants that can be determined by solving the 4 equations above.

Once they are known, the colour value at the target point can be determined from

A+Bxtarget+Cytarget+Dztarget=Colour value at this target point.

I wrote a program within the vb component to determine A B C and D. it is amazing how fast the code runs within the vb component. I needed to do 100,000 interpolations and the time taken was a massive 15 seconds.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service