Message Boards Message Boards

Reflect a plot on the other side of the axe y?

GROUPS:

Hi guys! How could I reflect the plot on the other side of the axe y (like the image) so I can work on two wheels? Is there any method of Mathematica or...?

Quadrilatero[q_, xA_, yA_, Lc_, L2_, L3_, modo_, xD_, yD_] :=
 Module[
  {xB, yB, L5, \[Theta]5, c, \[Alpha], \[Theta]2, xC, yC, \[Theta]3},
  xB = xA - Lc;
  yB = yA;
  L5 = Sqrt[(xD - xB)^2 + (yD - yB)^2];
  \[Theta]5 = ArcTan[xD - xB, yD - yB];
  c = (L5^2 + L2^2 - L3^2)/(2 L5 L2);
  If[modo > 0, \[Alpha] = ArcCos[c], \[Alpha] = -ArcCos[c]];
  \[Theta]2 = \[Theta]5 + \[Alpha];
  xC = xB + L2 Cos[\[Theta]2];
  yC = yB + L2 Sin[\[Theta]2];
  \[Theta]3 = 0;
  {\[Theta]3, \[Theta]2, {{xA, yA}, {xB, yB}, {xC, yC}, {xD, yD}}}
  ]

Manipulate[
 Module [{sol, coordinate, qq, xD, xA, yD, yA, modo, q},

  q = \[Pi];

  xD = -0.75;
  yD = 0;

  xA = s; 
  yA = 0.30;

  modo = 1;
  sol = Quadrilatero[q, xA, yA, Lc, L2, L3, modo, xD, yD];
  coordinate = sol[[3]];

  Show[

   (* Plot Traiettoria Nera *)
   ParametricPlot[
    Quadrilatero[qq, xA, yA, Lc, L2, L3, modo, xD, yD][[3]][[2]],
    {qq, 0, q + 0.00001},
    PlotRange -> {{-1, 1}, {-.2, .4}},
    AspectRatio -> .5,
    PlotStyle -> {Black, Dashed}],

   (* Plot Traiettoria Blu *)
   ParametricPlot[
    Quadrilatero[qq, xA, yA, Lc, L2, L3, modo, xD, yD][[3]][[3]],
    {qq, 0, q + 0.00001},
    PlotRange -> {{-1, .2}, {-.2, .4}},
    AspectRatio -> .5,
    PlotStyle -> {Blue, Dashed}],

   (* Plot Aste *)
   ListLinePlot[coordinate,
    PlotRange -> {{-1, .2}, {-.2, .4}},
    AspectRatio -> .5,
    PlotStyle -> Thick],

   (* Plot Ruota *)
   ListLinePlot[{coordinate[[3]], coordinate[[4]]},
    PlotRange -> {{-1, .2}, {-.2, .4}},
    AspectRatio -> .5,
    PlotStyle -> {Thickness[0.1], Opacity[0.08], Red}
    ],

   Graphics[
    {
     (*LightBlue,Opacity[0.2],Rectangle[{-0.75,-0.2},{0.75,0.4}],*)
     Gray, Thick, Disk[{xA, yA}, .02], Disk[sol[[3]][[4]], .02],
     Orange, Thick, Disk[sol[[3]][[2]], .02], Disk[sol[[3]][[3]], .02]
     }
    ]

   ]
  ],

 {{s, -0.035}, 0.04, -0.075, Appearance ->   "Open"},
 {{Lc, .1}, 0.04, 0.14, Appearance ->  "Open"},
 {{L2, 0.7}, 0, 2, Appearance ->  "Open"},
 {{L3, .1}, 0, .25, Appearance ->  "Open"}

 ]

I attatched even the .nb file, but I don't know why I get a lot of errors when I open the file and still I don't "Evaluate Notebook", why?

Attachment

Attachment

POSTED BY: Lorenzo Cristofori
Answer
8 days ago

You can do it by showing your plot together with a Scaled version:

With[
 {ruotaSinistra =
   Show[(*Plot Traiettoria Nera*)
    ParametricPlot[
     Quadrilatero[qq, xA, yA, Lc, L2, L3, modo, xD, 
        yD][[3]][[2]], {qq, 0, q + 0.00001}, 
     PlotRange -> {{-1, 1}, {-.2, .4}}, AspectRatio -> .5, 
     PlotStyle -> {Black, Dashed}]
    (*etc*)]}, 
 Show[ruotaSinistra, 
  Graphics[Scale[ruotaSinistra[[1]], {-1, 1}, {0, 0}]]]]

Replace the (*etc*) with the rest of your plot.

POSTED BY: Gianluca Gorni
Answer
8 days ago
Attachment

Attachments:
POSTED BY: Lorenzo Cristofori
Answer
8 days ago
POSTED BY: Gianluca Gorni
Answer
8 days ago

There is no answer :) maybe something went wrong publishing the replay.

POSTED BY: Lorenzo Cristofori
Answer
8 days ago

My answer got lost too. I would advise to use the graphics primitives, such as Line, instead of ParametricPlot when you are simply drawing a few straight lines. ParametricPlot is for curves. Your code would also be cleaner.

POSTED BY: Gianluca Gorni
Answer
7 days ago

Group Abstract Group Abstract