Tag Info

New answers tagged


To my knowledge, it is not directly possible to compute the outline of objects with the provided morphological image processing functions. I use the outline of connected components very often too, mostly for visualising, but I think something like this should really be included in ComponentMeasurements. Since you know that the distance between outline pixel ...


The problem can be posed as a Traveling Salesman Problem, where we have a salesman starting at a city (or a point) and has to visit every other city once while minimizing his total distance. pts = boundary[[Last@FindShortestTour[boundary, Method -> "CCA", DistanceFunction -> ManhattanDistance]]]; Show[ ListPlot[spiel, PlotStyle -> Gray], ...


Ugly + undocumented solution: Graphics`Mesh`MeshInit[]; make[pts_] := PolygonArea[With[{order = ConvexHull[pts]}, Append[pts[[order]], pts[[order[[1]]]]]]]


As you didn't specify that any randomness was required, the natural solution to your problem for $n$ points and circle of radius $r$ is to find the $n$ complex $n$th roots of $r$, then translate them by the complex number $z = (x, y)$. To implement that, a "natural" thing is to use David Park's Presentations add-on ...


Here is a simple one, p sets how many points you want, q the radius and point the position of the center mycircle[p_, q_, point_:{0,0}] := Table[{q Cos[2 Pi k /p], q Sin[2 Pi k /p]} + point, {k, p}] Graphics[{Yellow, Point /@ mycircle[12, 1], Black, Point /@ mycircle[12, 1, {1, 1}], Green, Point /@ mycircle[12, 1, {2, 0}], Red, ...


Just for fun: SetAttributes[parts, Listable]; parts[z_] := {Re[z], Im[z]}; randomCirclePoints[n_, center_, radius_] := Block[{z}, parts[ z /. NSolve[(Exp[I RandomReal[{0, 2 Pi}]] (z - {1, I}.center))^n == radius^n, z] ] ] Graphics[ {Red, Point@randomCirclePoints[33, {2.5, 1}, 4]}, Frame -> True]


func[cntr_, rad_, n_, ang0_] := Graphics[{Circle[cntr, rad], {Red, PointSize@0.02, Point[Table[rad{Cos [ang0 + j],Sin[ang0 + j]}, {j, 0, 2 Pi - 2 Pi/n, 2 Pi/n}]]}}] Here cntr is centre of circle, rad is radius, n is the number of points/segments, ang0 is just specifying where to start. Manipulate[ func[{0, 0}, 1, num, a], {{num, 3}, ...

Top 50 recent answers are included