# Tag Info

15

Mathematica makes this fairly simple. We can define a region region = RegionDifference[Disk[{a, 0}, a], Disk[{0, 0}, b]] (* BooleanRegion[#1 && ! #2 &, {Disk[{a, 0}, a], Disk[{0, 0}, b]}] *) You can visualise this quite simply, for specific values of a and b with the following line Block[{a = 3, b = 1}, Region[region]] and an integrand ...

7

Here's an approach you could try, making use of ListContourPlot to build a RegionMemberFunction: First I'll make some sample data. This should just be replaced by your actual stuff: cutout = Region@Disk[{-2, 3}, 3]; concaveShape = RegionDifference[Disk[{0, 0}, 3], cutout]; distFunc = RegionDistance[cutout]; data = Flatten[ Table[r*{Cos[q], Sin[q]}, {q, ...

7

Working with mesh regions (i.e., using DiscretizeRegion) instead of region primitives (e.g., Cuboid) will produce objects that can be rendered more easily. body = RegionUnion[ DiscretizeRegion @ Cylinder[{{2.55,0,0},{4.45,0,0}},0.55], RegionDifference[ DiscretizeRegion @ Cylinder[{{2.5,0,0},{4.5,0,0}},0.6], DiscretizeRegion @ ...

7

Using @Michael's suggestion brings the timing down about an order of magnitude. There are 120 components after using LogicalExpand: components = List @@ LogicalExpand[ Reduce[1 > y > 0 && First @ reg1, {r[1], r[2], r[3], r[4]}] /. _Equal -> False ]; //AbsoluteTiming Length[components] {6.53425, Null} 120 Computing integral over ...

6

Sometimes, it is easier to discretize before intersecting. BoundaryDiscretizeRegion@RegionIntersection[ Map[ BoundaryDiscretizeRegion[#, MaxCellMeasure -> (1 -> 0.05)] &, {Cylinder[{{0, 0, -2}, {0, 0, 2}}], Cylinder[{{0, -2, 0}, {0, 2, 0}}], Cylinder[{{-2, 0, 0}, {2, 0, 0}}]} ] ]

5

Here's my take on solving it algebraically: DiskRadius[Disk3D[_, _, radius_]] := radius; RotateZToNormal[Disk3D[_, n_, _]] := RotationTransform[{{0, 0, 1}, n}]; MoveToDiskCenter[Disk3D[p_, _, _]] := TranslationTransform[p]; TransformUnitDiskTo[d_Disk3D] := RightComposition[RotateZToNormal[d], MoveToDiskCenter[d]] Project2D = Most;(*leave out z component to ...

5

A circle with center at $p$ radius $r$ and orientation $\vec n$ normalized, can be represented as $$c_i \to \{p_i, r_i \vec n_i\}$$ A circle $$c_0 \to \{p_0, r_0 \vec n_0\}$$ can be drawn with the parametric $$p = p_0 + r_0 \vec e_1\cos\mu +r_0\vec e_2\sin\mu,\ \ \mu\in (0,2\pi]$$ where $\vec n_0, \vec e_1, \vec e_2,$ form an orthonormal basis. ...

5

This is a little awkward: GreenFunction[{-Laplacian[u[x, y], {x, y}], DirichletCondition[u[x, y] == 0, True]}, u[x, y], {x, y} ∈ HalfPlane[{{0, 0}, {1, 0}}, {0, 1}], {ξ, η}] Log[((y + η)^2 + (x - ξ)^2)/((y - η)^2 + (x - ξ)^2)]/(4 π) Unfortunately, replacing HalfPlane[{{0, 0}, {1, 0}}, {0, 1}] with equivalent (in the sense of RegionEqual[])...

4

You consider tw0 3D-regions, that's why its onlye possible to calculate a volume! Try dV=Volume@RegionIntersection[cyl1, cyl2] (*0.000249282 *) To get an approximation of the disk area divison by the thickness of your pseudo-disc gives the result! addendum The workaround cyl2 isn't necessary. Try disk = ImplicitRegion[({x, y, z} - v2).n2 == 0&&...

4

Maybe this function does the trick: F[{p1_, n1_, r1_}, {p2_, n2_, r2_}] := Block[{A1, A2, v, w1, w2, area1, area2, angle}, A1 = Orthogonalize[Join[{n1}, IdentityMatrix[3]]][[2 ;; 3]]; A2 = Orthogonalize[Join[{n2}, IdentityMatrix[3]]][[2 ;; 3]]; angle = Min[VectorAngle[n1, n2], VectorAngle[n1, -n2]]; If[angle < 1. 10^-12, {w1, w2} = r1 ...

4

I have described integrating Mathematica and the open source 3D modeling tool, Blender 2.79b, in previous answers here and here. Your geometry does have some small features and concavity that can cause many meshers problems. Blender appears to be able to handle it. You will need to learn some python scripting to facilitate the integration but there are ...

3

It seems that the DiscretizeGraphics code doesn't know how to handle the SplineClosed->True option of the BSplineCurve object. As a workaround, you can use my FullBSplineCurve function to convert the SplineClosed->True option into an equivalent SplineKnots specification, and then perform the discretization: DiscretizeGraphics @ FilledCurve @ ...

3

I tried to separate NMinimize j[a_?NumericQ, b_?NumericQ] := First@NMinimize[1 + a t+ b t^2 , t] but RegionPlot[j[a, b] >= 0, {a, 1, 3}, {b, 1, 4}] (*Show::gtype: Success is not a type of graphics. ... *) gives several error messages. As a workaround you might try zw = Flatten[Table[{a, b, j[a, b]}, {a, 0, 3, .1},{b, 0, 4, .1}], 1] (*message: ...

3

This seems like it ought to work, but throws an exception right at the end. Building on the the example in the question, but with the length of the cylinders defined by a variable len that I can play with: v1 = {0.5, 0.5, 0.5}; n1 = {1, 1, 1}; v2 = {1, 1.5, 0}; n2 = {1, 1, 0}; d = 4; len = 10; Draw the cylinders and also a hperplane located at the ...

3

This is a problem that I often encounter and am working on a solution. In the meantime, a simple hack that I’ve found useful is to draw a polygon with a hole on top of the contour plot. If you define the hole such that it corresponds to the boundary of the area within which you want the contours To be shown then the contours that lie outside the hole will ...

3

val = Values@Solve[y^2 == 3 x && y == 2 x - 6, {x, y}]; p1 = Plot[{Sqrt[3 x], -Sqrt[3 x], 2 x - 6}, {x, 0, 6}, AspectRatio -> 1, PlotStyle -> Black]; p2 = Plot[{Sqrt[3 x], -Sqrt[3 x]}, {x, 0, val[[1, 1]]}, AspectRatio -> 1, Filling -> {1 -> {2}}, FillingStyle -> LightBlue, PlotStyle -> Black]; p3 = Plot[{Sqrt[3 x], 2 ...

2

Area@ImplicitRegion[{y^2 < 3*x && y > 2*x - 6}, {{x, 0, 5}, {y, -3, 10}}] -(3/16) (3 Sqrt[17] - Sqrt[2] (9 - Sqrt[17])^(3/2) - Sqrt[2] (9 + Sqrt[17])^(3/2)) and BoundaryDiscretizeRegion[ ImplicitRegion[{y^2 < 3*x && y > 2*x - 6}, {{x, 0, 5}, {y, -3, 10}}], MaxCellMeasure -> (1 -> 0.1) ] Alternatively, you can ...

2

If we first use DiscretizeRegion, then it's no problem on version 10.1. RegionMeasure@DiscretizeRegion@polygon 0.54

2

This is an extended comment to demonstrate the results on my system \$Version (* "12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019)" *) Clear["Global`*"]; ineq1 = r[2] + y r[3] > r[1] + y r[2] && (-1 + y) r[2] + r[4] < y r[3]; reg1 = ImplicitRegion[ ineq1, {{r[1], 0, 1}, {r[2], 0, 1}, {r[3], 0, 1}, {r[4], 0, 1}}]; int[y_] := Assuming[1 ...

2

Using color as the fourth dimension has severe limitations for regions that are solid in that you can only see the color of the surface of the region. While Opacity could be used to see "into" the solid region, the colors would be muddled together and you would not be able to appreciate the fourth dimension. ineq = α >= 2 β && 2 σ >= γ &&...

2

As @J.M. pointed out in the comments, the key here is the function RegionMember. Since you already know the region that you want to work with, namely Ellipsoid[XYMean, 1 XYCoVarMat], you can use Select as With[{rmf = RegionMember[Ellipsoid[XYMean, 1 XYCoVarMat]]}, Select[XYDATA, rmf]] {{0.997126,0.575375},{1.67482,1.73},{0.71546,1.72933},<<39325>>,...

1

Here is my solution based on @lan's idea. Let xyz 1st, 2nd and 6th column of data. Let's plot it in 3D. ListPointPlot3D[xyz] Let's extract first layer of point in 3D. 218 is found by try and error. pts = Most /@ TakeSmallestBy[xyz, Last, 218]; ListPlot[pts] These points are not ordered. ListLinePlot[pts] Let's order them q1 = ReverseSortBy[Select[...

Only top voted, non community-wiki answers of a minimum length are eligible