Blender - Intersection between 2 objects deletes part of my first object - boolean

I'm making a chess piece (a bishop) and I am trying to make the top notch.
For this purpose, I made a new cube, resized it and put on the place to make the cut.
I want to make a cut using a modifier: Boolean, intersecting the two objects.
The problem I am facing is that while intersecting, the top UV Sphere that simulates the 'hat' of the bishop disappears.
What I did so far:
- Remove Doubles
- CTRL+J to join Bishop+Hat(UV Sphere) to make 1 component
Nothing helped and when trying to intersect, the UVSphere-hat disappears.
Why? How to solve?
Here is the bishop before modifier, with hat:
Here is the .blend file to catch the problem faster:
Thank you for your help :-)

The boolean modifier offers two different solvers that produce different results. You want the intersect operation with the carve solver. You also want to hide the cube that you are using for the intersection otherwise you won't see the hole that it has cut out.

Just to go straight to the point I'll add the reply here and select sambler's excellent answer as right.
In my case the Cube which was going to intersect with the bishop HAD NEGATIVE SCALE.
If you have similar problems, check if your objects scale/parameters have negative parameters

Related

Overlapping Polygon Outline in Openscad

I am totally new to openscad.
I am trying to generate two overlapping polygons (2D). I would just like to observe the outlines of both shapes at the same time.
I have managed to generate two different shapes. Although the shapes overlap, the renderer appears to show the outline of the combined shape with the inner part is filled in with colour.
How might I achieve my goal if the shapes were simply two overlapping squares?
I would be glad to see your code to understand exactly what you're trying to describe.
In any case, you must know first that openscad have several rendering types:
the f5 one is the quicker and doesn't really calculates the final result, only its image on the screen (that's why you cannot export with it)
the f6 one which does all the calculation of the points of the mesh and then render it (that's what you do to export)
the debug ones that are similar to f5
I think f5 could be your solution but it will look a bit "glitchy" because of the superposition of the two shapes. The fact is that I don't think openscad is made for what you want to do because you can consider that all that you put in your script is in a big union() block so when you press f6 all the independent shapes are combined into one and I don't think there is a way to prevent that. I should add that I think that the 2D functions of openscad are probably made to be used with the extrude functions to make 3D volumes for which the overlapping doesn't have a lot of sense.

Holes in 2D circle collider

I try to begin new game development that has rotating circle that has one or many holes as in the attached image , the problem is I need to use circle collides for the big circle., in addition I need to use small collides for the smaller holes to prevent and particles(smaller circles ) input the circle and to count no of collisions occurred
enter image description here
The circle collider itself does not have this functionality since it can only check collisions between perfect circles. (Behind the scenes all circle colliders just check the distance between points and these distances do not work with holes) The best solution I can think of would be to use a polygon collider and make a rough circle that you can then remove parts of (would require some advanced geometry but not impossible). I have tried simillar things in 3D and with the mesh collider, removing parts of it using a method known as CSG (Wikipedia) and something simillar should be possible in 2D however it is really, really hard and even experienced programmers struggle to come up with a system that can handle every scenario.
All hope is not lost though, depending on what you need the collision for, there might be other ways. If you just need to check if two objects intersect and don't want rigibodys and stuff to interact with the collider just checking the distance between the big circle and the object (too figure out if it's close enough) and then checking the distance between the object and the holes (too see if it's inside a hole on thus not colliding) is the best way to solve the issue.
I'm sure someone who have done more in this field than I have will be able to help you out but without more information of what you need it's impossible to say. It all depends on the circumstances!

MATLAB - Filling in the empty region of an ellipse/skull shape?

I have been attempting to fill in a binary image in Matlab so that I am left with the entirety of this oval-like image like this.
However, I have been running into an issue in actually being able to define the red region. I have tried the following:
Using the bwconvhull function to fill the shape accurately, but then I do not know how to get rid of the inner shape to isolate just the red region.
I have also attempted to trace the boundary of the binary region but to no avail. I am not entirely sure what to do after tracing the boundary. I have attempted to trace just the inner boundary, but the bwtraceboundary function simply follows the entirety of the borders (on the inside and outside of the skull).
Are there any similar functions to bwconvhull where I am able to expand a region from the center outward? My major difficulties have been in isolating either (a) the inner boundary of the skull or (b) the inner "black" region where the brain should be. My coding attempts can be found below:
Issue (a) - Tracing boundaries
hole=imread('Copy CT.jpg');
BW=im2bw(hole,.9);
dim=size(BW);
col=round(dim(2)/2);
row=min(find(BW(:,col)));
boundary = bwtraceboundary(BW,[row,col],'S');
x=boundary(:,2);
y=boundary(:,1);
Issue (b) - Isolating only the center
hole=imread('Copy CT.jpg');
BW=im2bw(hole,.9);
CH=bwconvhull(BW);
KH=CH-BW;
KH2=bwareaopen(KH,200);
Are there any particular functions that would be worth trying, or would there be another way to isolate the center of the circle so I can only highlight the red region? Any insight would be greatly appreciated!
I would approach this with these steps:
apply an edge detection filter so you end up with two ellipse-ish shaped parts: an inner and outer ellipse.
apply an algorithmic ellipse-fit to the inner ellipse. There are some good examples out there, but I don't have one on me.
subtract the bwconvhull boundary with the inner ellipse.
subtract all parts of your new oval that overlap with the white portions of the original image.
I am sorry I don't have actual code to back up this approach, but this will get you pretty close. You may need more steps to clean up the final result.

Drawing a polygon by a lot of dots

My desired output is moving a lot of dots to visualize some words.
The effect is similar to this video http://www.youtube.com/watch?v=Le13by2WM70 .
I think this problem could be split into two sub-problem.
The first is how to extract the path from a vector font.
The second is how to moving dots to visulize that polygon.
There are some tools could solve first part, but I have not idea about the second part.
Anyone has done this?
You could probably do pretty well by just sampling points on a regular grid, with a little jitter added in to avoid looking too computery. All you need to do is check if you are "inside" or "outside" of the path. For inside, place a fish (or dot); for outside, no fish.

Finding area with CGContextEOFillPath

I am interested in using the CGContextEOFillPath feature provided by apple. I am guessing with the way the EOFill works, it probably has a way to take the filled in areas and calculate an area.
So my question is does anyone know of a way to use CGContextEOFillPath and find the area of the filled in sections.
If this isn't something that is easily done, maybe some pointers to a better way of doing this would be helpful. Though I need to use the EO style graphing.
Thanks.
What do you mean "Calculate the area"?
As in calculate the surface area of a complex shape?
It depends on your shapes.
Are they all polygons?
What about circles?
There are well known formulas for calculating the area of a polygon. (Wikipedia has it) Part of that calculation involves using an ABS() function because shapes drawn "counterclockwise" have the opposite sign as those drawn "clockwise". If you're looking to simulate the EO behavior, you can simply ignore the sign change, because, for you, it's desirable.
If you have more complicated shapes that involve curves, then you need to break the problem down into multiple parts - one part to solve for polygons - one to solve for circles - one to solve for other shapes, etc.