1
$\begingroup$

I want to make two plots, p1 and p2, of the same ellipse. In p1 the ellipse is rotated 30 degree and p2 in ellipse not rotated.

p1 = 
  GeometricTransformation[
    ContourPlot[x^2 + y^2/49 == 1, {x, -10, 10}, {y, -5, 5}, 
      PlotPoints -> 100, MaxRecursion -> 1],
    RotationTransform[30 Degree]];

p2 = 
  ContourPlot[x^2+y^2/49 == 1, {x, -10, 10}, {y, -50, 50}, 
    PlotPoints -> 100, MaxRecursion -> 1];

Show[p1, p2, PlotRange->Automatic]  

But I get the following message:

Could not combine the graphics objects in

How can I solve this problem?

$\endgroup$
3
$\begingroup$

GeometricTransform doesn't work on your Graphics. The documentation says that it works on geometric objects. It easier if you simply transform your equation

rot = Thread[{x, y} -> RotationMatrix[-Pi/180*30].{x, y}]
eq1 = x^2 + y^2/49 == 1
eq2 = eq1 /. rot

ContourPlot[Evaluate[{eq1, eq2}], {x, -10, 10}, {y, -10, 10}]

Mathematica graphics

If you like to use GeometricTransform, then you need to apply it to the graphics-primitives and not the whole graphics. Therefore, you need to replace the line primitives inside your plot:

f = GeometricTransformation[#, RotationTransform[30 Degree]] &;
ContourPlot[Evaluate[eq1], {x, -10, 10}, {y, -10, 10}] /. l_Line :> f[l]

Mathematica graphics

|improve this answer|||||
$\endgroup$
  • $\begingroup$ thanks for your reply.your method use RotationMatrix,I am not sure if any method use RotationTransform $\endgroup$ – kittygirl Mar 6 '18 at 16:10
1
$\begingroup$

Mathematica's geometric region capabilities makes what you want to do very simple.

p2 = ImplicitRegion[x^2 + y^2/49 == 1, {x, y}];
p1 = TransformedRegion[p2, RotationTransform[30 °]];
Show[Region[p1, BaseStyle -> Red], Region[p2, BaseStyle -> Blue], Frame -> True]

ellipses

|improve this answer|||||
$\endgroup$
1
$\begingroup$

Why not use Circle primitives instead of ContourPlot?

Graphics[{Red, Circle[{0,0}, {1,7}], Blue, Rotate[Circle[{0,0},{1,7}], 30 Degree]}]

enter image description here

|improve this answer|||||
$\endgroup$
0
$\begingroup$

I think there is no need to make it complicated (just a personal opinion based on the use of minimal MMA functions, although I acknowledge and value the other answers). Just use the equation of the rotated ellipse in the plane.

However a question rises: 30 degrees rotated in what direction?

Here, the rotation is from y-axis to x-axis (positive, clockwise):

ContourPlot[Evaluate[((x Cos[#] - y Sin[#])^2 + (y Cos[#] + x Sin[#])^2/49 == 1) & /@ 
{0, \[Pi]/6}], {x, -10, 10}, {y, -50, 50}, PlotRange -> {{-10, 10}, {-10, 10}}, 
PlotPoints -> 50]

enter image description here

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.