Tag Info

New answers tagged

3

Another approach: Manipulate[ Graphics3D[{GeometricTransformation[#, RotationTransform[ angle Degree, {b, c, d}]] & /@ {InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}], Arrow[{{0, 0, 0}, {0, 0, 1}}]}, InfiniteLine[{0, 0, 0}, {b, c, d}]}, PlotRange -> Table[{-3, 3}, {3}]], {angle, 0, 360, Appearance -> "Labeled"}, ...


5

For a starter Manipulate[Graphics3D[{EdgeForm[None], Opacity[.3], Green, poly = Polygon[.5 {{-1, -1, 0}, {-1, 1, 0}, {1, 1, 0}, {1, -1, 0}}], Polygon[.5 {{-1, 0, -1}, {-1, 0, 1}, {1, 0, 1}, {1, 0, -1}}], Polygon[.5 {{0, -1, -1}, {0, -1, 1}, {0, 1, 1}, {0, 1, -1}}], EdgeForm[None], Opacity[0.7], {Red, GeometricTransformation[poly, ...


10

There is a one-liner (if you have wide enough screen) Histogram@ComponentMeasurements[#, "Area"][[;; , 2]] &@ WatershedComponents@DistanceTransform@Import@"http://i.stack.imgur.com/k0EUJ.png"


7

Edit: 4x faster after refactoring and using {# - #2, +##} &[+##, Abs[# - #2]] & instead of Sort/@. Let we have the following 1D intervals $$ [a_1,b_1], [a_2,b_2], [a_3, b_3]. $$ Then we can take all these edges of intervals and sort them. For example, ...


3

pts = RandomReal[{-1, 1}, {8, 2}]; vm = VoronoiMesh[pts] Using a variation of this method in a related Q/A to associate points and the Voronoi cells they belong: vcells[p_, reg_] := With[{rm = RegionMember[reg]}, Polygon[Join[Pick[p, rm[p]],#]]&/@Partition[Join[reg[[1]],{reg[[1,1]]}],2,1]]; mps=MeshPrimitives[vm, 2]; cs = vcells[pts, #] & ...


2

I made first voronoid diagram. (version 10) SeedRandom["LookAtThisSeed"] pts = RandomReal[{-1,1},{10,2}]; mesh = VoronoiMesh[pts]; grid = MeshPrimitives[mesh,2]; fig = Show[ {Graphics[{EdgeForm[{Thick,Gray}],Opacity[0],grid}]}, Graphics[{PointSize[Large],Red,Point[pts]}], Graphics[{PointSize[Medium],Blue,Point[MeshCoordinates@mesh]}]] And ...


4

There is a risk that I didn't understand what you want to do here but I'll try to answer your question to the best of my ability. First we generate some random points and the corresponding voronoi mesh. SeedRandom["LookAtThisSeed"] pts = RandomReal[{-1, 1}, {8, 2}]; mesh = VoronoiMesh[pts] We can use MeshCoordinates to get the vertex coordinates of ...


4

Looks to me to be a bug in RegionPlot. I say fhis beccause DiscretizeRegion @ TransformedRegion[Rectangle[{0, 0}, {1, 1}], {#1^(1/3) + #2, 1 + #2} &] gives as expected.


10

Here is another way to compute the surface area of a 3D convex hull: SeedRandom[0] pts = RandomReal[5, {50, 3}]; chull = ConvexHullMesh @ pts; Then: Tr @ PropertyValue[{chull, 2}, MeshCellMeasure] 86.8845076 Update This approach is good because you have access to individual face areas and with PropertyValue you can do cool things like display the ...


9

For fun, here is an approach that uses the graphics generated from the mesh. Lets generate some points: SeedRandom[0] pts = RandomReal[5, {50, 3}]; chull = ConvexHullMesh @ pts; Create a graphics object from it and discretize it: gr = Graphics3D[GraphicsComplex[MeshCoordinates[chull], {MeshCells[chull, 2]}]]; And here is the area: Area @ ...


9

Area@RegionBoundary@ConvexHullMesh@pts For example, consider a cube: pts = Flatten[Table[{x, y, z}, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}], 2]; convexHull = ConvexHullMesh[pts]; convexHullSurface = RegionBoundary[convexHull]; RegionMeasure[convexHull, #] & /@ {0, 1, 2, 3} (* {∞, ∞, ∞, 1.} *) RegionMeasure[convexHullSurface, #] & /@ {0, 1, 2, 3} (* {∞, ...


6

This can also be done with the built-in plotting functions, e.g. RevolutionPlot3D[ {2 + Cos[t], Sin[t]}, {t, 0, 2 Pi}, PlotPoints -> {4, 4}, MaxRecursion -> 0, Mesh -> All, PlotStyle -> Opacity[.2] ] Note the PlotPoints and the MaxRecursion ...



Top 50 recent answers are included