Hi, I’m working with an irregular blob (generated and deformed as a SOP) contained inside a square. What I need is to control in a stable and accurate way the percentage of area that the blob covers relative to the square (e.g. 25%, 36.8%, 50%, etc.). I can’t use image-based masks or pixel-based approaches, since I need to work with real-world units and measure the area in specific physical units (e.g. square centimeters). At the moment I’m driving the blob using a target_area parameter, but this approach is not precise or stable, and the resulting area does not match the target value accurately.
Thanks a lot! Unfortunately, this is not exactly what I need. What I’m looking for is a way to set a specific percentage value and have TouchDesigner generate a single, static 2d blob that covers exactly that percentage of area.
there is something called the Shoelace or Gauss’s area formula that can calculate the approximate area of a 2D shape. For this to work, convert the x and y coordinates of your shape into CHOP channels and scroll offset each channel in a separate Shift CHOP by a single sample. Then multiply x and y via Math CHOPs and sum up all resulting values using the Analyze CHOP. The two resulting channels you subtract from each other and multiply by 0.5.
Now that you have the area of the initial shape, you can divide the target area that it is suppose to occupy by the initial shape’s area and take the square root of it which as a result now can be used as a scaling factor to the shape itself.
It would be important to mention that in your example file, the shape is not a 2D deformed shape but the deformation is in 3D along the z axis only looking like a 2D deformed blob as the SOP viewer’s camera is perspective. If you inspect the x and y coordinates for this circle you will see that the circle is still perfectly in shape. You would have to project the circle onto a 2D plane using some camera matrices to generate a 2D version of what it looks like in 3D.
In any case it is quite impossible to calculate the surface in an algorithmic way. Too much parameters in the definition of the blob, in the noise and in the interpolation to obtain curves.
In physic, when you cannot calculate a volume, you fill it with liquid and you mesure the liquid (or you plunge it in a liquid and you mesure the volume augmentation). My proposition is a little bit similar.
The proposition and the comment from Markus are very clever, mainly the necessity to reduce the noise dimensions and the need od a view axe. But the Gauss area formula is an approximation working with quite “regular” blob, my method, using orthographic camera and analyse top is (IMHO) much more accurate.
I stole some idea from Markus to make a more accurate proposition. You have the choice !
I agree that a projection and render is a better approximation. Especially the rectangle size must be know anyways, so there is no downside to a analytic approach.
Thanks a lot for the help, guys! Here’s the semi-finished project - I wanted to share it with you. Now I just need to focus on smoothing it out to make sure it’s 3D printable. Thanks again