# Tag Info

14

lin[cam_, obj_][t_] := cam t + (1 - t) obj s[cam_, obj_] := First@Solve[lin[cam, obj][t][[3]] == 0, t]; tr[cam_, obj_] := lin[cam, obj][t] /. s[cam, obj] // FullSimplify And that's it: tr[ ] i your transformation function. Let's test it with a Rubik's cube, simulating the video you linked. The following boring part is building the cube. We will make only ...

14

Here's a simple method that seems to work. Call the grid above img. Find the best/strongest line in the image: lines = ImageLines[img, MaxFeatures -> 1] We'll need the slope of this line - here's a function to do that slope[s_, e_] := ArcTan@@(e - s); (shorter version thanks to nikie). This can be applied as slopeLine = First[slope @@@ lines] For ...

10

If you have v9, here's an alternative solution: first I calculate the gradient and gradient orientation for each pixel gray = ColorConvert[img, "Grayscale"]; orientation = GradientOrientationFilter[gray, 3]; gradient = GradientFilter[gray, 3]; then I create a weighted histogram from those: wd = WeightedData[Flatten[ImageData[orientation]], ...

10

try: f = FindGeometricTransform[pointSetNoise, pointSetPerfect] I know it's too short for an answer, but that's it. The result can be tested like this: ListPlot[{f[[2]][pointSetPerfect], pointSetNoise}, Axes -> False, Frame -> True]

9

RotationTransform[a Pi, {1, 0, 0}] is nothing more than a matrix, so you can compose/combine such functions using matrix multiplication. For example: Graphics3D[{EdgeForm[None], GeometricTransformation[Cylinder[], RotationTransform[.5 Pi, {1, 0, 0}].RotationTransform[0.2 Pi, {0, 1, 0}].RotationTransform[0.1 Pi, {0, 1, 0}]]}] In the above code ...

7

Here is a method based on image manipulations, which means I pre-suppose a certain pixel resolution with which the crash is detected: tip[rg_] := {EdgeForm[Thin], FaceForm[White], Polygon[{{0, 4}, {0, 0.2}, {0.5 - rg, 0}, {0.5 + rg, 0}, {1, 0.2}, {1, 4}}], FaceForm[Black], Rectangle[{0.4, 0}, {0.6, 1}]}; box = {EdgeForm[Thin], FaceForm[Blue], ...

7

Use Composition: Manipulate[Graphics3D[{EdgeForm[None], GeometricTransformation[Cylinder[], Composition[ RotationTransform[a Pi, {1, 0, 0}], RotationTransform[b Pi, {0, 1, 0}], RotationTransform[c Pi, {0, 1, 0}]]]}], {{a, 0}, -1, 1}, {{b, 0}, -1, 1}, {{c, 0}, -1, 1}, SaveDefinitions -> True] (I'm not sure which order you ...

7

As an addition to @bills's answer you can rotate by the mean of the slope of all the detected lines. slopeLine = slope @@@ lines meanslope = Mean@Join[Select[slopeLine, # > -1 &], Select[slopeLine, # < -1 &] + Pi/2] ImageRotate[img, -meanslope]

6

This works by making an interpolation function in initialization, which represents the surface. Each time the prob is moved, it finds the Euclidean distance between the current tip position and the surface at the x-coordinates at the time. It checks that this distance is not smaller than some crash tolerance constant value set in the initialization. (This ...

5

If you did want to transform the plot, you can use something like: Manipulate[ Plot[(1 - p2)^2/(p2^2 + (1 - p2)^2), {p2, 0, 1}, AxesLabel -> {"p2", "p1"}, PlotRange -> {-1, 1}] /. Line[a__] :> Line @ Map[{(#[[1]] - γ)/(1 - γ), (#[[2]] - γ)/(1 - γ)} &, a], {γ, -1, 0.5}] which transforms the points that define the Line.

5

You probably want to transform the function, not the plot: f[p2_] := (1 - p2)^2/(p2^2 + (1 - p2)^2) Plot[f[p2], {p2, 0, 1}, AxesLabel -> {"p2", "p1"}] t[p2_, g_] := (f[(p2 - g)/(1 - g)] - g)/(1 - g) Manipulate[Plot[t[p2, g], {p2, 0, 1}, AxesLabel -> {"p2", "p1"}], {g, 0, 0.999}]

5

Testing overlapping polygons One can use the testpoint function from this answer to 9405, which I will call inPolygonQ: inPolygonQ[poly_?MatrixQ, pt_?VectorQ] := Round[(Total @ Mod[(# - RotateRight[#]) &@ (ArcTan @@ (pt - #) & /@ poly), 2 Pi, -Pi]/2/Pi)] != 0; In V8/V9, there is the undocumented function GraphicsMeshInPolygonQ which may ...

4

Here is my solution using RevolutionPlot3D to draw the disk layers, it's faster; First convert the image to data rows: imgd = Map[First[#] &, ImageData[ColorConvert[img, "Grayscale"]], {2}]; rows = Reverse /@ Transpose[imgd]; Define the function to draw the disk slices: ClearAll[disk] disk[row_List, nPoints_] := Module[{ lr = Length[row]}, ...

4

ImageTransformation works with functions, not tables. It should be straightforward to define a function that carries out the same transformation as the table, but you will need to be aware that the #[[1]] and #[[2]] arguments go from 0 to 1 (across the image) so you will need to design the function to handle this input range. For example, you might want a ...

4

If the problem is that the transformation function is slow to compute, a simple way to create and use a look-up table is to memoize the function: (* create an example image *) image = RandomImage[1, {30, 20}, ColorSpace -> "RGB"] ~ ImageResize ~ Scaled[10] (* define the transformation function with memoization *) mem : func[{x_, y_}] := mem = {x + 0.01 ...

3

I think you have to make sure that your transformation function always handles input cleanly. Here's a test you can do to see what goes into your function. (And I think you can use real coordinates if you use the DataRange option.) i = ImageResize[ExampleData[{"TestImage", "Mandrill"}], {20, 20}]; The function: f[pt_] := (Print[pt]; {pt[[1]], pt[[2]]}); ...

3

I'd say this is the sort of thing LinearFractionalTransform[] was designed for: With[{γ = 2/3}, MapAt[GeometricTransformation[#, LinearFractionalTransform[{IdentityMatrix[2], {-γ, -γ}, {0, 0}, 1 - γ}]] &, Plot[(1 - p2)^2/(p2^2 + (1 - p2)^2), {p2, 0, 1}, AxesLabel -> {"p2", "p1"}, PlotRange -> All], 1]] ...

2

You can define any matrix as a transformation in LinearFractionalTransform: t = LinearFractionalTransform[{{1, 2, 1}, {4, 5, 3}, {1, 1, 9}}] However, this can only be applied to a geometric object using Graphics[GeometricTransformation[Rectangle[], t]] if the matrix is affine. The subtlety is that the TransformationFunction itself need not be ...

1

Although your code produces a picture of a "spiral staircase", there are some choices of parameters the escape my understanding, so let's look at simplified version with some debugging code added. Module[{t, g}, g = Graphics3D[ t = Table[ GeometricTransformation[ Cuboid[{1, 0, 0}, {.01, .2, .1}], {RotationMatrix[a, {0, 0, 1}],(* ...

1

If you indent the code, it's easier to see its structure Graphics3D[ Table[ GeometricTransformation[ Cuboid[{1, 0, 0}, {.01, .2, .1}], {RotationMatrix[ a, {0, 0, .05}], {.001 Cos[a], .001 Sin[a], a}}], {a, -[Pi], 2 Pi, .2} ], Boxed -> False ] Graphics3D is a container for three-dimensional graphics objects, ...

1

A rotation in 3D does not have a centre point, technically -- just an axis. The reason that Solve complains is that there should be a one-parameter family of solutions. But since the TransformationFunction is in terms of approximate reals, it is slightly off. Things that should cancel out exactly and produce a null space of dimension one do not. But they ...

1

There is a Wolfram Blog post that explains this as a subproblem: Mapping GPS Data, by Robert Raguet-Schofield. That was published in 2009 and I think is pretty nifty. But I'd recommend looking into out new URLFetchAsynchronous and perhaps updating the code. Below you see parts in the blog where he seamlessly goes from patches to a single map:

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