Drawing a polygon by a lot of dots - visualization

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.

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.

How do I make a Maze Generator on Scratch?

I am currently in High School, and I am in an APCSP (AP Computer Science Principles) class, which in my case is learning in Scratch programming. I am confused and have practically no idea what I'm doing. Scratch is very confusing and I feel like it's pointless to learn.
My question is this: Can anyone help me on how to make a Maze Generator on Scratch, as this is my project and it's giving me struggles.
Thank you.
It's actually possible to build with scratch but depends on what you are looking for. I assume you want to generate a simple maze like in old fashioned 8-bit games like boulder dash.
First decide on the size of your maze: for example 5 x 5 blocks.
If you want to create a maze, imagine drawing it on a grid on paper. Blocks are either "empty" or filled in. Our maze can be represented by numbers. The empty blocks are represented by a 0 and the filled blocks with a 1.
You could visualize that matrix like this if all blocks are empty:
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0
Adding a border wall while keeping the inside empty would look like:
1,1,1,1,1,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,1,1,1,1
Using a "list" variable to store this information would fit best within the possibilities of MIT Scratch.
In this case, you need to understand that each block in our maze is represented by a position in above matrix. You could draw numbers on a piece of paper in the shape and size of your grid / matrix as a reference to remember the position of each block if that makes it easier.
We also need to look at how our maze will relate to the Stage size. The width and height in pixels of a default scratch project is 480x360.
A 5 x 5 maze is divided in blocks of 480 / 5 = 96 width and 360 / 5 = 72 height. In other words, a block needs to be 96x72 pixels, based on a full screen maze.
Next step, is creating a sprite representing the visualization of the blocks of the maze. I would keep the first "costume" of our block sprite empty, and create a fully filled block to represent the walls of the maze.
After that, we need to programmatically create our maze. I made an example you can explore of random drawing of the blocks of a maze:
https://scratch.mit.edu/projects/278731659/
(You can change the rows & columns value to see it scale up, but remember the limit to the amount of clones the block sprite can have is 300)
This is just to get you started and by no means a complete solution. I just hope this helps you think in the right direction.
You can make this more advanced, by adding a function to explore and correct our randomly drawn grid to generate a walkable path from position x to position y. A rule you can program is for example: Every empty position in the grid should have at least two other empty positions in the spaces above, below, left and right of it.
There are many different ways to do this; whether this is with sprites and stamp or 2D lists and pen. Either way, the main component is the algorithm. This wikipedia page gives details on how maze generation works and few different algorithms. There is also a video series by The Coding Train here where he creates a maze generator with the 2D list method from above (this method is a bit harder on scratch, however). Either way, the best thing to do is to look at examples others have made, figure out how they work, and try to recreate them or make them better. Here's a good place to get started.
Scratch IS truly pointless! A simple maze generator would have you use the pen to draw predefined shapes (Such as a long hallway or intersection). You should also make (invisible) squares to separate everything and have the program draw in the squares.
I will put a link later that leads to a sample project that has the code.
Check out this video by griffpatch
https://www.youtube.com/watch?v=22Dpi5e9uz8
This was one of my projects, and the instructor provided this video for everyone to follow and expand from.

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

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

Automated placement of points/landmarks on shape outline using MATLAB

I'm just beginning with Image analysis in MATLAB.
My goal is to do an automated image segmention on images of plant leaves.
I have had reasonable success here thanks to multiple online resources.
The current objective, the reason why I'm placing this question here, is to able to place 25 equidistant points along each half of the margin/outline of leaf, like described in following image:
For the script to be able to recognize each half of the leaf, user can put two points within the GUI. One of these user-defined points will be on the base of leaf and the other on tip of leaf. It would be even better if a script would be able to automatically recognize these two features of the leaf.
For the output, I would like a plain text format file containing image coordinate of each point.
I'm not asking for a ready made script here, but looking for a starting point.
One way I think this can be done is by linearizing/open up the outline in such a way that it becomes a straight line. This can be done by treating any of user placed point/landmark as breakpoint. Once a linear outline is obtained it can again be broken into two halves at other user defined point and now points can be placed. One point to bear in mind here is that the placement of points for each half should start from the end that corresponds to the same breakpoint/user-defined point in each half. Now these straight lines can be superimposed on original image for reconstruction.
Thank you very much.
Parashar

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.