Hot answers tagged

12

EulerMatrix is available in MMA 10. To obtain the matrix for the transformation shown in your sketch, apply EulerMatrix[{α,β,γ},{3,1,3}] This transformation is known as the x-convention, because the second rotation is about x'-axis. The Wikipedia designates this by ZXZ. Those who do not have MMA 10 can obtain the same x-convention transformation using ...


10

To address your actual problem: If you're just looking to re-orient your B-spline cylinder, there's no need to go through the Euler angles. Here's one way. Consider the following cylinder: myCyl = BSplineSurface[{{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 1}, {0, 1, 1}, {1, 1, 1}, {1, 0, 1}}}, ...


8

With your figure l1 = Line[{{0, 1}, {1, 1}}]; cir = Circle[{1, 0}, 1, {-π/2, π]/2}]; l2 = Line[{{0, -1}, {1, -1}}]; geom = {l1, cir, l2}; g = Graphics[geom]; and the rectangle marker l = 0; hw = 0.01; hh = 0.05; marker = Rasterize@Magnify[Graphics@Rectangle[{l - hw, hh}, {l + hw, -hh}], 0.07] one can create a binary image from the figure bg = ...


7

You can use RotationTransform. With[{rot = funs[[3]] /. Inner[Rule, {x, y}, RotationTransform[π/2][{x, y}], List]}, ContourPlot[rot, {x, -.5, .5}, {y, -.5, .5}] ] Hope this helps. Also with Manipulate Manipulate[ With[{rot = funs[[3]] /. Inner[Rule, {x, y}, RotationTransform[θ][{x, y}], List]}, Quiet@ContourPlot[rot, {x, -.5, .5}, {y, -.5, ...


7

You can achieve the desired transformation with the ImageForwardTransformation function. The transformation effect is easily visible on a grid image: grid = Rasterize[ Graphics[Rectangle[], GridLines -> {Range[.05, .95, .05], Range[.05, .95, .05]}, GridLinesStyle -> Directive[{White, Thick}], Method -> {"GridLinesInFront" -> True}, ...


7

If you leave ContourPlot outside you can get quite nice performance: static = ContourPlot[45 x^2 + 20 y^2 == 45, {x, -2, 2}, {y, -2, 2}, Frame -> False]; dynamic = ContourPlot[8 x^2 + 4 x y + 5 y^2 == 9, {x, -2, 2}, {y, -2, 2}, Frame -> False, ContourStyle -> Orange]; Manipulate[ Graphics[{ First@static, ...


6

Thanks for J.M.'s answer for coordinates transformation. With[{transpts = Map[Composition[TranslationTransform[{1, 1, 1}], RotationTransform[{{0, 0, 1}, {1, 2, 1}}]], pts]}, Graphics3D[ {PointSize[Large], Point[pts], Blue, Line[pts], Arrow[Tube[{{0, 0, 0}, {0, 0, 0} + 2 Normalize@{0, 0, 1}}]], Black, PointSize[Medium], Point[{0, 0, ...


6

Some of this code is based on the last example of the docs on GradientOrientationFilter You can also smooth out the resulting path and reparametrize the interpolation based on the curve length to get a "constant velocity" displacement for the rectangle- l1 = Line[{{0, 1}, {1, 1}}]; cir = Circle[{1, 0}, 1, {-π/2, π/2}]; l2 = Line[{{0, -1}, {1, -1}}]; geom = ...


5

rotation = {x, y}.{{Cos[t], Sin[t]}, {-Sin[t], Cos[t]}}; f[t_] = funs[[3]] /. {x -> rotation[[1]], y -> rotation[[2]]}; Manipulate[ ContourPlot[f[t], {x, -.3, .3}, {y, -.3, .3}], {t, -\[Pi], \[Pi]}]


4

This is surely a bug. The misbehavior certainly persists through V10.2. In fact, the two images below are of the same computation. The only difference is where they appear on the screen (as I scrolled the notebook, the transformed red disk jumped around). μ = 0.16255558520216132` + 0.1849493244071408` I; pic[τ_] := Block[{d, ds, arc}, d = Disk[{0, ...


3

Motivation In Mathematica most curves are ultimately rendered using Line, which has a straightforward derivative. Therefore it makes sense to create a function that solves the problem for the particular case of a Line object. For example pts = Flatten[Cases[Plot[Sin[x], {x, 0, 2 Pi}], Line[pts_] :> pts, Infinity], 1]; is the list of points which make ...


3

Here's how I arrived at this (admittedly, quite ugly) mapping function: The "right" function to map points from cylinder coordinates to image coordinates in a pinhole camera model is the one MarcoB linked to in his comment. In a nutshell: {Sin[u],Cos[u],v,1} converts from cylinder coordinates u,v to (homogeneous) 3d coordinates which you then multiply by ...


2

Just as a complementary and extended comment and as was recently observed in a related post, you get exactly the same problem if, not surprisingly, you use geometric transformation functions instead: Given the initial object to transform: circles = {Circle[{0, 0}, 1], Circle[{0, 0.5}, 0.5]}; the OP transformation: t1 = Rotate[Scale[circles, 12], -45 ...


2

I understand the solution proposed in the comments by @YvesKlett has bee sufficient. However, I gave it a go out of curiousity and this seemed to work fine: Code: (*Dummy function*) f[x_, y_] := Sin[x^2 + y^2] Exp[-x^2] + Cos[x^2 + y^2] (*Sample data*) g2 = Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}, PlotPoints -> 50, Axes -> False, Boxed -> ...


2

You have to use the TransformationMatrix instead of the TransformationFunction: TransformationMatrix@result[[2]] {{0., -1., 0., 4.}, {1., 0., 0., 1.}, {0., 0., 1., 0.}, {0., 0., 0., 1.}} TransformationMatrix@result[[2]].m {{0., -1., 0., 2.}, {1., 0., 0., 2.}, {0., 0., 1., 0.}, {0., 0., 0., 1.}}


1

In version 10.2 (perhaps going back to 10.0, but I cannot verify that), by default STL's are imported as MeshRegion objects. Assuming that casefn is a string representing the path to an STL file, you can see all the elements available for import from the file Import[casefn, "Elements"] (*{"BinaryFormat", "BoundaryMeshRegion", "Comments", ...


1

Here is a quick answer (based on @J.M.'s comment) for a basic rotation: STLdata = Import["MyFile.stl", "GraphicsComplex"]; RotatedSTL = Graphics3D[ GeometricTransformation[STLdata, RotationTransform[30 Degree, {1, 1, 1}]], Axes -> True] Export["MyFileRotated.stl", RotatedSTL, {"STL","BinaryFormat" -> False}]


1

I guess there is some floating-point-related issue here... This works: f[t_] := RegionPlot[ TransformedRegion[ Rectangle[{-1, -1}, {1, 1}], { Indexed[#1, {1}] (1 + t (Indexed[#1, {2}]^2 - 1)) + 2 t, Indexed[#1, {2}] (1 + t (Indexed[#1, {1}]^2 - 1)) + 2 t } & ], PlotRange -> {{-1 + 2 t, 1 + 2 t}, {-1 + 2 t, 1 + 2 t}} ] ...


1

You can extract the matrix from result using Part: result[[2, 1]].m {{0., -1., 0., 2.}, {1., 0., 0., 2.}, {0., 0., 1., 0.}, {0., 0., 0., 1.}}



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