Hot answers tagged

15

One way is to compute the solid angle subtended by the cow viewed at the point by summing signed solid angles corresponding to the cow's polygonal faces. If the total is 4 pi, the point is inside the cow; if 0, outside. Background Quoting Wikipedia, "Solid angle is the two-dimensional angle in three-dimensional space that an object subtends at a point." ...


13

This is basically a rehash of code I posted in a prior thread on this topic. The underlying method is to shoot a ray from the point and see how many surface triangles it intersects. elsie = ExampleData[{"Geometry3D", "Cow"}]; verts = First[Cases[elsie, GraphicsComplex[a_, ___] :> a, Infinity]]; pgons = First[Cases[elsie, Polygon[x_, ___] :> x, ...


8

I am writing this answer only to address the Wizard's comment of "not obvious". Recall that if you take two nonzero vectors $\mathbf v_1$ and $\mathbf v_2$ as your basis, you can then represent any other vector as a linear combination of these two ($x \mathbf v_1 + y \mathbf v_2$). In Mathematica, this is equivalent to the expression Transpose[{v1, v2}].{x, ...


5

EDIT My original post was unnecessarily complex (pun?) and I have taken the advice of Kuba. This is not really an advance but I post it for fun: v1 = {2, 1}; v2 = {-1, 1}; f[x_, y_] := {x, y}.{v1, v2}; Manipulate[ Row[{Show[Plot[{x, x^2, 5 Sin[x]}, {x, 0, 5}, PlotRange -> {0, 5}], ParametricPlot[{x, y}, {x, 0, 5}, {y, 0, 5}, MeshFunctions ...


5

The solution is to work in grid positions, e.g. gridX × height and gridY × width to come up with screen coordinates that have to be corrected by an offset to line up the grid-origin one is using with its true screen coordinates. The position in the grid can be obtained by using Quotient thus returning the grid coordinates as integers. In the given example ...


3

You have problem because your variable a is already a graphics object. This works for me: file = Export["fig.pdf", Plot[Sin[x], {x, 0, 2 π}]] g = First[Import[file]] Graphics[{g[[1]], Inset[x^2 + y^2 == 1, {200, 200}]}]


3

headF1 gets the Head of the expression in the specified part of the matrix. headF2 uses the fact that Part 0 of an expression is its Head. ClearAll[headF1,headF2] headF1= Head[#[[## & @@ #2]]] &; headF2= #[[## & @@ #2]][[0]] &; SeedRandom[1] mat = RandomChoice[{Ellipse[], Point[]}, {5, 3}] {{Point[], Point[], Ellipse[]}, ...


3

Are you looking for cp1 = ContourPlot[Cos[x] + Cos[y] == 1/2, {x, 0, 4 Pi}, {y, 0, 4 Pi}] testData = Prime[Range[25]] lp1 = ListPlot[testData, PlotStyle -> Red] Show[cp1, lp1] but be carefull and check the sequence of Show, because Show uses the options from the first graphic Show[lp1, cp1] cp2 = ContourPlot[Cos[x] + Cos[y] == 1/2, {x, 0, 25}, ...


3

If you were to be more careful in your use and scoping of variables, everything would be fine. {m, k, g, r0} = {1, 1, 9.8, 2}; With[{ Q = 0, coord = {r[t], θ[t]}, T = 1/2 m (r'[t]^2 + r[t]^2 θ'[t]^2), V = 1/2 k (r[t] - r0)^2 - m g r[t] Cos[θ[t]]}, Lagrangiana[T_, V_, Q_, coords_List] := Module[{L = T - V}, (D[D[L, D[#, ...


2

Here is a kick --- sunday --- answer p1 := Plot[Sin[x], {x, 0, 1}] p2 := Plot[Cos[x], {x, 0, 1}] GraphicsGrid[{{p1}, {p2}}] Export["Where you want\\name of the file", pasted GraphicsGrid] You may copy the GraphicsGrid on clicking on the vertical bar


2

Perhaps, ClearAll[inpField] inpField[arg_, fs_: 5] := InputField[arg, FieldSize -> fs, Background -> Yellow, Appearance -> "Frameless"] Interpretation[{f = {-y, -2 x}, xmin = 0, xmax = 1, ymin = 0, ymax = 1}, Panel@Row[{"StreamPlot[", inpField[Dynamic[f], 12], ", \n ", Invisible["StreamPlo"], "{x, ", inpField[Dynamic[xmin]], ",", ...


2

As far I can tell your problems are due to rasterization that you introduced into your graphics output. You need to tell us how you made the enlarged image of the small part of your output that you show us, because if you were to let Mathematica plot from exact numbers and do the magnification, the graphics look great, even when no Antialiasing -> True ...



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