Hot answers tagged

5

Clear["Global`*"] $Version "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" From the documentation for ColorFunction, "With the usual default setting ColorFunctionScaling -> True, all arguments supplied to func are scaled to lie in the range 0 to 1." You need to use ColorFunctionScaling -> False when you don't ...


5

Takes a few seconds, but ImplicitRegion works: body = ImplicitRegion[ y^2 + z^2 <= r^2 && z >= 0 && -L/2 <= x <= L/2, {x, y, z}] (ℐ = ρ MomentOfInertia[body, Assumptions -> L > 0 && r > 0]) // MatrixForm m Cancel[ℐ/(ρ Volume[body, Assumptions -> r > 0 && L > 0])] // MatrixForm


5

An alternative to using RegionFunction is to use ConditionalExpression Plot3D[ ConditionalExpression[ Sin[x*y], (x < Pi/3 || x > 2 Pi/3) && (y < Pi/3 || y > 2 Pi/3)], {x, -Pi, Pi}, {y, -Pi, Pi}, AxesLabel -> Automatic]


5

Plot3D[Sin[x y], {x, -Pi, Pi}, {y, -Pi, Pi}, RegionFunction -> Function[{x, y, z}, Nor[Pi/3 <= x <= 2Pi/3, Pi/3 <= y <= 2Pi/3 ]]] Also ir = ImplicitRegion[{Nor[Pi/3 <= x <= 2Pi/3, Pi/3 <= y <= 2Pi/3 ]}, {{x, -Pi, Pi}, {y, -Pi, Pi}}]; Plot3D[Sin[x y], {x, y} ∈ ir] same picture Plot3D[Piecewise[{{Sin[x y], Nor[Pi/3 <= x ...


3

I played around a bit with this problem and noticed that all numeric functionalities become significantly faster when you use a polygon with machine-precision points. So if you want to use NMaximize or the like, I highly recommend this. Furthermore, here's a numerical implementation that uses SignedRegionDistance: Clear[x]; poly = Polygon @ N[{{0, 1}, {0, 6},...


3

Conjecture We believe that the center of the max circle should be lie in the line segment. pts = {{0, 1}, {0, 6}, {4, 10}, {8, 10}, {11, 7}, {11, 4}, {7, 0}, {1, 0}}; poly = Polygon[pts]; fig1 = Graphics[{{LightGreen, poly}, {Red, Point[pts]}, Blue, Text[#, RegionCentroid[RegionDifference[Disk[#, 1.3], poly]]] & /@ pts}]; p1 = {x, y} /. (...


3

The problem mentionned by @Szabolcs in his answer is solved on Mathematica version 12.2 (the problem is present on Mathematica 12.1) $Version pts = {{-1, 0}, {-1, 1}, {0, 0}, {1, 1}, {1, 0}}; g = Graphics[{FilledCurve@BSplineCurve[pts, SplineClosed -> True]}] DiscretizeGraphics[g]


2

Other similar way. f2[x_, y_] := If[! (π/3 <= x <= (2 π)/3 || π/3 <= y <= (2 π)/3), Sin[x*y], Undefined] f3[x_, y_] := Piecewise[{{Sin[ x*y], ! (π/3 <= x <= (2 π)/3 || π/3 <= y <= ( 2 π)/3)}}, Undefined] f4[x_, y_] := Piecewise[{{None, (π/3 <= x <= (2 π)/3 || π/3 <= y <= ( 2 π)/3)}}, Sin[x*y]]


2

Relate link : Smooth Boxcar function (Rectangle Pulse function) Here we also use mollifier (https://en.wikipedia.org/wiki/Mollifier) just a test,not so effect. We chose a ParametricRegion reg1 which can replace to other ImplicitRegion etc. We can also adjust $\epsilon=10^-8$ to other small positive real number. φ[x_, y_] = Piecewise[{{Exp[-1/(1 - (x^...


1

psi = -4 (x^2 + y^2); gradPsi = Grad[psi, {x, y}] R = TransformedRegion[Rectangle[], {Indexed[#, 1] - First@gradPsi /. x -> #[[1]], Indexed[#, 2] + Last@gradPsi /. y -> #[[2]]} &]; Show[Graphics[{Opacity[.5], Blue, Rectangle[]}], RegionPlot[R, PlotStyle -> Opacity[.5, Red]], PlotRange -> All, Frame -> True, FrameTicks -> ...


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