1
$\begingroup$

I am editing an old .nb that generate the polarization map of a vector vortex beam from the Stokes parameters ( S1,S2,S3) stored in 3 different matrices (S1medie,S2medie,S3medie). the code initialize a 900x900 matrix named finalmatrixand then replace some elements with Rotate[Circle[{i, j}, {a[S3medie], b[S3medie]}], ψ[S1medie, S2medie]]. Finally, by applying Graphics[{Thick, finalmatrix}, ImageSize -> {900, 900}], I get the correct polarization pattern.

The problem is that, at that time, I used Rotate[Circle[...]]to display the ellipses and it does not allow me to modify the ellipses like I want ( adding a rotating arrow for example ).For this reason I planned to switch to ParametricPlot, but when I try to build an equivalent matrix the Graphics function doesn't work anymore. I suppose the reason behind this is that the Heads are different since ParametricPlot has already head Graphics.

I can't post the entire code nor the matrices here but this is the crucial part of it:

latocella = 3;
passo = 10;
χ[S3medie_] := ( 1/2 ) ArcSin[Abs[S3medie]];
a[S3medie_] := 8.0*Cos[χ[S3medie]] ;
b[S3medie_] := 8.0*Sin[χ[S3medie]] ;
ψ[S1medie_, S2medie_] := 
  If[S1medie == 0 && S2medie == 0, 0, (1/2) ArcTan [S1medie, S2medie]];
Ellipse[i_, j_, S1medie_, S2medie_, S3medie_] := 
 Rotate[Circle[{i, j}, {a[S3medie], b[S3medie]}], ψ[S1medie, 
   S2medie]]  
fun[i_, j_] := 
 finalmatrix[[j*latocella + (latocella + 1)/2, 
    900 - i*latocella - (latocella + 1)/2]] = 
  Ellipse[j*latocella, 899 - i* latocella, S1medie[[i, j]], 
   S2medie[[i, j]], S3medie[[i, j]]]

finalmatrix = Table[Null, {l, 1, 900}, {k, 1, 900}];
Outer[fun, Range[1, 299, passo], Range[1, 299, passo]];
Graphics[{Thick, finalmatrix}, ImageSize -> {900, 900}]

the parametric equation i tried to implement was:

ParametricPlot[
 RotationMatrix[ψ[S1medie, S2medie]].{i + 
    8.0*Cos[χ[S3medie]]*Cos[x], 
   j + 8.0*Sin[χ[S3medie]] *Sin[x]} , {x, 0, 2 π}]

my questions are:

1)Does anyone know how I can obtain the same result with parametricplot?

2) is it possible to use SparseArray to save memory ?

3) is there a faster alternative?

$\endgroup$
1
$\begingroup$

Simplify your code immensely by placing just a rotated ellipse in each grid point, then using GraphicsGrid to render them together:

mycircle = 
  GraphicsGroup[{Circle[], Arrowheads[.2], Arrow[{{0, 1}, {0.1, 1}}], 
    White, Circle[{0, 0}, 1.2]}];
GraphicsGrid@Table[Graphics[
   GeometricTransformation[mycircle, 
    ShearingTransform[RandomReal[{-1, 1}], {1, 0}, {0, 1}]]
   ], {5}, {5}]

enter image description here

$\endgroup$
1
  • $\begingroup$ thanks , after few changes it worked like charm. $\endgroup$ – Alucard Nov 21 '17 at 9:34

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.