Tag Info

New answers tagged

2

I'm posting this just to show that in Mathematica, it is entirely possible to start from the definitions: pointTriangleDistance3D[pt_?VectorQ, tri_?MatrixQ] := Module[{p1 = First[tri], s, t}, Sqrt[MinValue[{SquaredEuclideanDistance[pt, p1 + {s, t}.Map[# - p1 &, Rest[tri]]], 0 <= s <= 1, 0 <= t <= 1, s + t <= 1}, {s, ...


5

Sorry I can't make sense of your Matlab code - too many nested Ifs. I don't know whether I've adapted belisarius' answer correctly: point = RandomInteger[100, {3}]; triangle = RandomInteger[100, {3, 3}] ; lines = Subsets[triangle, {2}]; nline[{start_, end_}, pt_] := Module[{param = ((pt - start).(end - start))/Norm[end - start]^2}, N@{pt, start + ...


3

Since no-one has done a RegionPlot3D, I'll do one. RegionPlot3D[ x^2 + y^2 + z^2 <= 1 && z >= 0 || (-5 < x < 5) && (-5 < y < 5) && (-0.5 < z < 0), {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, Mesh -> None, PlotPoints -> 120, PlotStyle -> Directive[Orange, Specularity[Yellow, 12], ...


3

Here is another simple way to draw a hemisphere that makes use of the symmetry axis: hemisphere = First@RevolutionPlot3D[Sqrt[1 - r^2], {r, 0, 1}, Mesh -> None]; Here you can vary the option PlotPoints if needed, to get a more or less dense polygon mesh. I also extract the contents of the Graphics3D object before using it. This needs to be done ...


6

To show that there's more than one way to skin a cat, here's another primitive-based method, using NURBS surfaces to render a hemisphere: With[{r = 1}, Graphics3D[{EdgeForm[], BSplineSurface[Outer[Append[First[#1] #2, Last[#1]] &, r {{0, 1}, {1, 1}, {1, 0}}, {{1, 0}, {1, 1}, {-1, 1}, ...


5

This peculiar method works in Mathematica versions 7 (thanks, Mr. Wizard!) and 8, but apparently no longer in version 9 (per rm): Graphics3D[{CapForm["Round"], Tube[{{0, 0, 0}, {0, 0, 0}}, {0, 1}]}, Boxed -> False] (I know CapForm["Round"] can be omitted, since it's the default; I just wanted to indicate that it's the reason for this behavior.) ...


1

Using whuber's method, we can generate a hemisphere with elevation $\alpha$ and horizon $\theta$ using ContourPlot as follows: \[Alpha] = 0; \[Theta] = 0; normal = Cross[{Cos[\[Theta]], Sin[\[Theta]], 0}, {Cos[\[Alpha]] (-Sin[\[Theta]]), Cos[\[Alpha]] Cos[\[Theta]], Sin[\[Alpha]]}]; ContourPlot3D[x^2 + y^2 + z^2, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, ...


5

ParametricPlot3D[{Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}, {u, 0, π}, {v, 0, π}, Mesh -> None, Boxed -> False, Axes -> None ] r = 0.5; d = {0, 0, 0.5} sphere = ParametricPlot3D[r {Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]} + d, {u, -π/2, π/2}, {v, -π/2, ...


1

Someone may find it useful. I'm sure this be implemented much efficient way in Mathemetica. Below is given two functions for: checking if the line intersects with a box in 3D - Intersection3DQ calculating 3D intersection points of a line and a box - Intersection3D . Intersection3DQ[p1_List, p2_List, boxMin_List, boxMax_List] := Module[ {c, d, e, ad, ...


0

With apologies for the third, yet again independent answer, I recommend calling igraph through RLink using this package (only if you have v9 of Mathematica). Please see the instructions on how to set up the package, then you can do: graph = AdjacencyGraph[{{1,0},{0,1}}]; res = IGraph["graph.get.isomorphisms.vf2"][graph, graph] Round[res+1] This will ...


6

I will use a slightly different example to demonstrate my method (which is in no way guaranteed to solve the problem perfect but just an approach). Firt we generate $100$ random cuboids with unique color for each of them, so we can have a bijection colorToIdxRules between the color set colorSet and the indice of the cuboids numObj = 100; numRay = 50; ...


2

Here's one possibility, using an undocumented function for the Delaunay triangulation: BlockRandom[SeedRandom[131, Method -> "MKL"]; (* for reproducibility *) pts = RandomReal[{0, 10}, {10, 2}]]; Graphics`Mesh`MeshInit[]; dt = Delaunay[pts]; Graph[Range[Length[pts]], UndirectedEdge @@@ dt["Edges"], VertexCoordinates -> pts] Compare: ...



Top 50 recent answers are included