Hot answers tagged

8

Here I randomly rotate points away from the pole by a distance along the surface that is drawn from a truncated normal distribution. I hope this is close to what you need: n = 1000; capc = 0.4; (* Pi/2: cover hemisphere, Pi: cover the whole thing *) dist = TruncatedDistribution[{-capc, capc}, NormalDistribution[0, 2]]; cvals = RandomVariate[dist, n]; dirs = ...


7

You can use Sphere instead of ImplicitRegion: RandomPoint[Sphere[{0,0,0,0}, 1], 2] {{0.318231, -0.429109, -0.496487, 0.684175}, {-0.623644, 0.379281, -0.651925, 0.205445}} Or with higher dimensions: RandomPoint[Sphere[{0,0,0,0,0,0,0,0,0,0}, 1], 2] {{-0.17768, 0.211006, -0.112154, 0.200347, -0.282798, -0.433921, -0.502452, 0.126637, 0.0389269, 0.576989}, {-...


5

x^2 + y^2 + z^2 + p^2 == 1 is the surface of a hypersphere. Since the surface has no thickness, RandomPoint has difficulty in locating a point. If instead you give the surface some small thickness, it can more readily be done. Clear["Global`*"] region = ImplicitRegion[1 - 10^-5 < x^2 + y^2 + z^2 + p^2 <= 1, {x, y, z, p}]; SeedRandom[1234] ...


4

We can workaround this issue with DelaunayMesh: BoundaryMesh[DelaunayMesh[pts10]]


4

This interesting problem can be solved numerically by computing InterpolationFunctions for the two sums of integrals in the last two lines of code in the Question. λ2 = -(1/2) + r + 1/(1 + r) - r^2 Log[1 + 1/r]; k = 0.5; r = 0.5; t = Flatten[Table[ R1 = ImplicitRegion[θ (v + r) > r && 2 θ v s + (1 - θ) r > λ1, {{θ, 0, 1}, {v, 0, 1}}]; R2 = ...


4

VoronoiMesh[X, MeshCellStyle -> {{1, "Interior"} -> {Thick, Red}, {1, "Frontier"} -> {Thick, Red}}] Alternatively, VoronoiMesh[X, MeshCellStyle -> {{1, "Boundary"} -> Opacity[0], {1, All} -> Directive[Thick, Red]}] same picture


3

Here is a slightly different approach also using OpenCascadeLink Needs["NDSolve`FEM`"] bmesh = ToBoundaryMesh[ohp, "BoundaryMeshGenerator" -> "OpenCasdade"] MeshRegion[bmesh] Note, however, there is a slight difference in the result compared to Tim's answer. In this case the union is created. I.e. no subdivision between the ...


3

Here is an option using OpenCascadeLink. OpenCascade is an open source 3D CAD package that often does a better job retaining sharp features with boolean operations and seems to be fairly robust. Needs["OpenCascadeLink`"] Needs["NDSolve`FEM`"] {length, beam, draft} = {50, 3, 4}; pmin = {0, 0, 0}; pmax = {length, beam, draft}; hull = ...


3

Clear["`*"]; x := Sin[a] Sin[b] Sin[c]; y := Sin[a] Sin[b] Cos[c]; z := Sin[a] Cos[b]; p := Cos[a]; x^2 + y^2 + z^2 + p^2 // FullSimplify; pts = Table[{x, y, z, p} /. Thread[{a, b, c} -> {RandomReal[{0, Pi}], RandomReal[{0, Pi}], RandomReal[{0, 2 Pi}]}], 10000]; Graphics3D[Point[Most /@ pts]] projected to xyz plane.


3

There appear to be some problems using HalfSpace. I've worked around this using an ImplicitRegion instead that matches up with the HalfSpace but produces a bounded object when discretized: reg = ImplicitRegion[-3 < {0.694747, 0.186157, 0.694747}.({x, y, z} - {0.622008, 0.166667, 0.333333}) < 0 && -2 < x < 2 && -2 <...


2

I now realize that the question can be solved analytically, for the most part, although not with ImplicitRegion. The constraints embodied in R1 and R2 can be solved to obtain θ in terms of v and parameters. r1c1 = Reduce[θ (v + r) > r && v > 0, θ] // Last (* θ > 1/(1 + 2 v) *) r1c2 = Reduce[2 θ v s + (1 - θ) r > λ1 && v > 0 &...


2

We can speed things up by not recomputing distances to previous objects. This requires fixing the seed points beforehand. The following is fast enough that you can get away with a much higher seed size, depending on how many balls you're looking to find. Also note that each iteration gets faster because we remove seed points that are no longer in the region. ...


2

The comment of Henrick Schumacher answered my question so I am posting it here: The RegionMeasure of a discrete point cloud is of course the counting measure (because RegionDimension[Point[{{0, 0, 0}, {8, 8, 8}}]] returns 0). And for two points it is equal to 2, no matter what the coordinates are.


2

The problem is that Abs has no built in derivative. One solution is setting Abs'[x_] := HeavisideTheta[x] Then you can do Plot[f'[x], {x, 0, 1}]


2

If I do the following incantation: bounds = RegionBounds[Rint] (* {{-1., 1.}, {-1., 1.}, {0., 2.}} *) Append[Rint, PlotRange -> %] I get this: This also often succeeds: Append[Rint, PlotRange -> {{-1.`, 1.`}, {-1.`, 1.`}, {0.`, 2.`}}] Either of these has usually failed in my trials (runs until I kill the kernel; succeeded only once each in say a ...


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