1
$\begingroup$

I have a 2D projection of a spherical object in the 3D space as given in the image below. The global orthonormal basis vectors are given as $\boldsymbol{x}$, $\boldsymbol{y}$, $\boldsymbol{z}$ and the local orthonormal basis vectors on the projection plane is given as $\boldsymbol{a}$, $\boldsymbol{b}$, $\boldsymbol{c}$ as in the image below.

enter image description here

For an object at $(-15,0,0)$ in the global coordinate system, the projection along the line $AD$ ends up at a point D with the coordinates $(-30,0,0)$ in the local coordinate system. When I create the 2D density plot of the projected object, it assumes the standard 2D basis as default and the projection ends up on the left side as in the image above.

With the local basis that I have set, I require the projection to end up on the right side or in other words I require the density plot with the same basis as the local basis ($\boldsymbol{a}$, $\boldsymbol{b}$, $\boldsymbol{c}$) of my projection geometry. For that, I want to flip the horizontal-axis of density plot so that the negative horizontal-axis values are on the right side of zero and the positive on the left of the zero. How do I do it?

The equations and the code are as follows:

FSR =   2. 2.71828^(-(( 0.0121267 (14.5272 + 0.34202 a)^2 (300. + 10. a)^2)/(-14.5272 - 0.34202 a)^2) - (0.25 (14.5272 + 0.34202 a)^2 b^2)/(-14.5272 - 0.34202 a)^2)

FSR2 = 2. 2.71828^(-((0.25 (9.39693 + 0.34202 a)^2 a^2)/(-9.39693 - 0.34202 a)^2) - (0.25 (9.39693 + 0.34202 a)^2 b^2)/(-9.39693 - 0.34202 a)^2)

DensityPlot[Max[FSR, FSR2], {a, -60, 60}, {b, -60, 60}, Mesh -> False, PlotPoints -> 200, PlotRange -> All, Exclusions -> None]

What I am trying to accomplish here is: enter image description here

Here is the Matlab code that does the job in MATLAB

   [a,b] = meshgrid(-50:1:50); 
   FSR = 2*2.71828.^(-((0.012126707038032768.*((14.527228357744116 + 0.3420201433256687.* a).^2).*(300 + 10 .*a).^2)./(-14.527228357744116 - 0.3420201433256687.*a).^2) - (0.25000000000000006.*((14.527228357744116 + 0.3420201433256687* a).^2).* b.^2)./(-14.527228357744116 - 0.3420201433256687.*a).^2); 
   surf(a,b,FSR);
   set(gca,'Xdir','reverse');
$\endgroup$
  • $\begingroup$ I would just apply the transformation to the coordinates before plot them...do we have to assume that $\vec{a}=-\vec{x}$? $\endgroup$ – José Antonio Díaz Navas Feb 13 '18 at 18:50
  • $\begingroup$ Can you post your code that produces your image? $\endgroup$ – OkkesDulgerci Feb 13 '18 at 18:59
  • $\begingroup$ @JoséAntonioDíazNavas The vector a⃗ =x⃗. $\endgroup$ – dykes Feb 13 '18 at 18:59
  • $\begingroup$ @OkkesDulgerci I use: DensityPlot[Max[FSR, FSR2], {a, -60, 60}, {b, -60, 60}, Mesh -> False, PlotPoints -> 200, PlotRange -> All, Exclusions -> None] $\endgroup$ – dykes Feb 13 '18 at 19:00
  • $\begingroup$ Why not exchange simply the x-y axis? BTW, your axes do not comprise a right-handed reference system... $\endgroup$ – José Antonio Díaz Navas Feb 13 '18 at 19:03
0
$\begingroup$

Change your range and step-size accordingly.

DensityPlot[Sin[x] Sin[y], {x, -3 Pi, 3 Pi}, {y, -5 Pi, 5 Pi}, 
 FrameTicks -> {{Range[-5 Pi, 5 Pi, Pi], 
    None}, {Transpose@{Range[-3 Pi, 3 Pi, Pi], 
      Reverse@Range[-3 Pi, 3 Pi, Pi]}, None}}]

enter image description here

Edit: Here is a dirty way to do it.

   FSR = 2. 2.71828^(-((0.0121267 (14.5272 + 0.34202 a)^2 (300. + 
              10. a)^2)/(-14.5272 - 0.34202 a)^2) - (0.25 (14.5272 + 
            0.34202 a)^2 b^2)/(-14.5272 - 0.34202 a)^2);

FSR2 = 2. 2.71828^(-((0.25 (9.39693 + 0.34202 a)^2 a^2)/(-9.39693 - 
            0.34202 a)^2) - (0.25 (9.39693 + 
            0.34202 a)^2 b^2)/(-9.39693 - 0.34202 a)^2);
p1 = Rotate[
   DensityPlot[Max[FSR, FSR2], {a, -60, 60}, {b, -60, 60}, 
    Mesh -> False, PlotPoints -> 200, PlotRange -> All, 
    Exclusions -> None, Frame -> False, ImagePadding -> All], 
   180 Degree];




p2 = DensityPlot[1, {a, -60, 60}, {b, -60, 60}, 
   ColorFunction -> GrayLevel, ColorFunctionScaling -> False, 
   FrameTicks -> {{Range[-60, 60, 20], 
      None}, {Transpose@{Range[-60, 60, 20], 
        Reverse@Range[-60, 60, 20]}, None}}, ImageSize -> 390];

Overlay[{p2, p1}, Alignment -> Right]

enter image description here Edit 2:

FSR[a_, b_] := 
  2. Exp[-((0.0121267 (14.5272 + 0.34202 a)^2 (300. + 
             10. a)^2)/(-14.5272 - 0.34202 a)^2) - (0.25 (14.5272 + 
           0.34202 a)^2 b^2)/(-14.5272 - 0.34202 a)^2];

FSR2[a_, b_] := 
  2. Exp[-((0.25 (9.39693 + 0.34202 a)^2 a^2)/(-9.39693 - 
           0.34202 a)^2) - (0.25 (9.39693 + 
           0.34202 a)^2 b^2)/(-9.39693 - 0.34202 a)^2];


data = Reverse /@ Tuples[Range[50, -50, -1], 2];

data2 = Max /@ Transpose@{FSR @@@ data, FSR2 @@@ data};

ListDensityPlot[Partition[data2, 101], MaxPlotPoints -> Infinity, 
 PlotRange -> MinMax@data2]

enter image description here

$\endgroup$
  • $\begingroup$ Sorry, I am new to Mathematica but this only changes the axis ticks and the image remains the same as before. How to transform the image simultaneously so that both axis and the image is flipped as per my question above?. $\endgroup$ – dykes Feb 13 '18 at 19:56
  • $\begingroup$ Is there any way to define a grid similar to MATLAB that would set up a coordinate system like I want?. $\endgroup$ – dykes Feb 13 '18 at 20:24
  • $\begingroup$ I don't know how Matlab's grid works. Can you give a small example that shows desired output. $\endgroup$ – OkkesDulgerci Feb 13 '18 at 20:31
  • $\begingroup$ Here is the Matlab code that does the job in MATLAB [a,b] = meshgrid(-50:1:50); FSR = 2*2.71828.^(-((0.012126707038032768.*((14.527228357744116 + 0.3420201433256687.* a).^2).*(300 + 10 .*a).^2)./(-14.527228357744116 - 0.3420201433256687.*a).^2) - (0.25000000000000006.*((14.527228357744116 + 0.3420201433256687* a).^2).* b.^2)./(-14.527228357744116 - 0.3420201433256687.* a).^2); surf(a,b,FSR); set(gca,'Xdir','reverse'); $\endgroup$ – dykes Feb 14 '18 at 10:31
  • $\begingroup$ The Mathematica equivalent to meshgrid would be {a, b} = Transpose[ Flatten[Outer[List, Range[-50, 50, 1], Range[-50, 50, 1], 1], 1]]; Seems complicated but the reason is that one usually would not do that in Mathematica... $\endgroup$ – Henrik Schumacher Feb 14 '18 at 11:28

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.