## algorithms – Minimize volume of cylinder that covers a clusters, with constraints

Let me start by pointing out the errors in the two algorithms you described:

• In both algorithmic scetches, there is the same error of assuming the maximum pairwise distance of the points in the 2D plane would be the diameter of the smallest enclosing circle. Looking at just three points, it should be clear why this is not correct: Instead, the diameter of a circle enclosing all points must be identical to the distance of either two points, or identical to the circle diameter of a subset of three points, where all the three points are on the convex hull of the full set (in 2D). This gives you a straightforward (partially) brute-force solution for the smallest enclosing circle problem (just iterate about over all pairs and triples of the points on the convex hull). See Smallest-Circle-Problem) for more sophisticated approaches.

• In the first scetch, there is the error of assuming the length of the cylinder must be identical to one of the pairwise distances of the points, which is not a necessary condition. The two points with maximum distance could be placed diagonally at the top and bottom of the cylinder, so the cylinder length being smaller than their distance: Hence I don’t think one should start with the general case first, I am pretty sure it is harder than the specialized case.

IMHO you had a good start with the second algorithmic scetch: finding all triplets which are suitable for a base side reduces the problem to a finite set of cylinder axis directions, and solving the problem when the axis direction is known is a lot simpler. Your idea of continuing with the projection to that plane is fine, but with a corrected version of the “enclosing circle” algorithm (see above). That should fix your second algorithm.

As an optimization, you could try to implement an algorithm for the triangulated 3D convex hull, and then check only the planes given by the triangles on the hull. That should reduce the number of planes to a large degree.

Beware, implementing a the 3D convex hull algorithm, or an efficient 2D smallest-enclosing circle algorithm may still be a challenge. An O(N^4) solution for the second problem is described here, a more sophisticated one is here.

Posted on Categories Articles

## webmathematica – How can I plot a hexagon inside this cylinder so that it is always in the same direction as the cylinder, no matter what the orientation is?

How can I plot a hexagon inside this cylinder so that it is always in the same direction as the cylinder, no matter what the orientation is? In addition, the hexagon must always be the same size as the cylinder.

For example, start at the origin (10,9,8) and go to (1,2,3)?

``````Graphics3D ({Cylinder ({{10, 9, 8}, {1, 2, 3}}, 0.5)}
``````

I tried this:

``````Table (Show (Graphics3D (Cylinder ({{0., 0., 0}, {0., 0., l}}, 1)), PolyhedronData ({"Prism", 6})), {l, 0.1 , 3, 0.1})
``````

Posted on Categories Articles

## Is it possible to find the radius of a cylinder, given only the volume and lateral area?

Is it possible to find the radius of a cylinder, given only the volume and lateral area? If so, what formula would be used?

## c# – Minimize area of cylinder that covers a clusers, with constrains

c# – Minimize area of cylinder that covers a clusers, with constrains – Software Engineering Stack Exchange
Posted on Categories Articles

## plotting – How to plot a hexagon inscribed on a cylinder in 3D? The cylinder is hollowed out in the form of a hexagon (Mathematica)

1. `RegionProduct` + `RegularPolygon` + `RegionPlot3D`

``````Show[RegionPlot3D[RegionProduct[RegularPolygon@6, Line[{{-1}, {1}}]],
PlotStyle -> Opacity[.5, Red], Boxed -> False],
Graphics3D[{Opacity[.2, Green], Cylinder[]}]]
`````` 2. `PolyhedronData`

``````prism6 = PolyhedronData[{"Prism", 6}]
`````` ``````Graphics3D[{Opacity[.3, LightBlue],
Cylinder[],
Opacity[.5, Red],
Scale[First @ prism6, {1, 1, 2}]},
Boxed -> False]
`````` Posted on Categories Articles

## I will do professional Packaging Design for your brand for \$35

#### I will do professional Packaging Design for your brand

Today, customers make a split decision based on what they see. That’s why it’s important to make sure that your visual presentation makes you appear unique, credible, trustworthy and authoritative. Your design only have one chance to make a first impression so if you want to make an impact, it’s vital that your product design is up to par.

I offer professional and innovative product packaging designs for individuals and brands dealing with Health & Beauty, Cosmetics & Luxury, Jewelry and Accessories etc

What you will get:

• Minimal yet professional and sleek design

• 100% premium and professional service

• JPG/PDF for print & AI editable source files

• Free for commercial use

• Start to finish support for every client

Please don’t hesitate to contact me if you have any question regarding anything to get started. .

Posted on Categories Articles

## Slice cylinder as region – Mathematica Stack Exchange

I am trying to slice a cylinder, and plot as a region, so I can apply a colour funtion like so: ``````RegionPlot3D({(x - 1)^2 + y^2 < 1 && x <= z},
{x, 0, 2}, {y, -1, 1}, {z, 0, 2},
ColorFunction -> (LABColor(1 - #3/2, #1 - 1, #2) &),
ColorFunctionScaling -> False, Mesh -> None, Boxed -> False,
Axes -> False, PlotPoints -> 100)
``````

However, I cant seem to rotate the colour function or the cylinder region. I looked here but can’t seem to apply it to this problem.

Ideally, I’d like to slice it with the plane as the variable, rather than altering the colour function or the cylinder, like so I was wondering if I should use `Boole` or `RegionIntersection`, but haven’t had any luck so far.

Vertical cross sections should look something like this which I created with a different methd:

``````labcross(n_, div_, div1_, div2_) :=
Flatten /@
Reverse(Table(LABColor(u, #, #2) & @@ {0, 0},
{u, 1/div1, 1, 1/div1})),
Reverse(Transpose(#2))}) & @@
Table(Table(Table(LABColor(u, #, #2) & @@
N@(v RotationMatrix(2 Pi x/div) . {1, 0}),
{u, 1/div1, 1, 1/div1}), {v, 1/div2, 1, 1/div2}),
{x, {n, div/2 + n}}));

With({n = 3}, Grid(Partition(
ArrayPlot(labcross(#, 2 n, 50, 25), Frame -> False,
ImageSize -> 300) & /@ Range@n, 3)))
``````

Posted on Categories Articles

## unity – Fade a texture effect as it nears the end of a cylinder mesh

In my game I have a laser beam that travels for about 15m, but abruptly stops due to the mesh the texture is attached to. How can I setup my shader graph so that the end of the texture fades away? I can’t find anything similar to this anywhere online, and have tried multiple things (gradient/colors with lerp attached to alpha) but just can’t figure it out as I’m too new to the whole shader graph thing. Anything helps, thank you.

Note: The texture is ‘animated’ and scrolls along the path of the beam using the shader graph  ## c++ – How to perform a fast ray cylinder intersection test?

First we’ll subtract the cylinder center from the ray origin, to translate our whole problem to be centered at (0, 0, 0).

Case 0: Inside

First, check if the ray origin is inside the cylinder from the start.

$$text{origin}_x^2 + text{origin}_z^2 leq text{radius}^2 quad text{and}quad -frac {text{height}} 2 leq text{origin}_y leq frac {text{height}} 2$$

If so, it’s conventional to return no hit (we only count hits going into the cylinder). Though you could instead invert the following cases to check for a hit exiting the cylinder.

Case 1: Above / Below

If our shifted origin is above $$frac {text{height}} 2$$ or below $$-frac {text{height}} 2$$, then we check whether its direction takes it closer to the cylinder:

$$text{origin}_y times text{direction}_y < 0 ?$$

If it does not, we know the ray is too high/low to ever hit the cylinder, and we can early-out with no hit.

Otherwise, we can advance the ray to the time $$t$$ when it crosses the plane of the cylinder’s top (or bottom):

$$t_{text{plane}} = -frac {text{origin}_y} {text{direction}_y}$$

The ray’s position at that time is $$vec p_1= vec {text{origin}} + t_text{plane} cdot vec {text{direction}}$$

If that point is inside the cylinder’s radius,

$${p_1}_x^2 + {p_1}_z^2 leq text{radius}^2$$

Then we have a hit against the top/bottom cap of the cylinder, with a vertical collision normal.

If not, we can proceed as though the ray had started somewhere beside the cylinder, rather than above/below:

Case 2: Beside

Next we’ll check if the ray hits the circle. For that we want to know the earliest positive time $$t$$ at which…

$$||vec {text{origin}} + t cdot vec {text{direction}}|| = r\ (vec {text{origin}} + t cdot vec {text{direction}})^2 = r^2\ t^2 cdot text{direction}^2 + t cdot 2(vec {text{origin}} cdot vec {text{direction}}) + text{origin}^2 – r^2 = 0$$

You can solve this with quadratic formula. Choose the smallest positive solution, and call it $$t_text{circle}$$. If there is no positive real solution, return no hit.

Then, as we did with case 1, find the position at that time: $$vec p_2= vec {text{origin}} + t_text{circle} cdot vec {text{direction}}$$

Now we check whether that’s on our cylinder, or if it missed:

$$| {p_2}_y| < frac {text{height}} 2 ?$$

If the hit is within this height range, then we have a hit, with collision normal parallel to $$vec p_2$$. Otherwise, we miss the cylinder and return no hit.

If you do find a hit, add the cylinder center back to the hit position $$vec p_1$$ or $$vec p_2$$ to get the hit position in world space.

Posted on Categories Articles