Skip to main content
added 1486 characters in body
Source Link
PlatoManiac
  • 15k
  • 2
  • 44
  • 76

Another way will be to simply take advantage of the CapForm primitives and get those rounded lines. I am using a transformation rule on the Graphics object generated by the PolarPlot function to change the default lines into a rounded one.

plot=PolarPlot[theta/2 Pi, {theta, 0, 20 Pi},Axes->None,PlotStyle->Black, PlotRange -> All]; plot/.Line[point_] :> {CapForm["Round"],Thickness[.03],Line[point]} 

enter image description here

Update: An accurate way to address the following requirement!

"I need to have this pattern also represented as a matrix"

  1. First discretize the 2D line plot of the spiral and form a region distance function based on that discrete curve.
  2. Sample a good number of points on the $\{x,y\}$ plane where the spiral lies.
  3. Use the region distance function to mark only those points which satisfy you trench thickness criterion.

Here is the commented code to generate the requested matrix:

reg=DiscretizeGraphics@plot;(* Step 1: Discretize 2D *) df = RegionDistance[reg]; (* Step 1: Distance function *) (* Step 3: Sample point but extend the bounding box by {-4, +4} *) samplePt=Outer[List, ##] & @@ (Range[##, .8] & @@@ (# + {-4, +4} &/@RegionBounds[reg])); (* Get your image matrix! TRENCH Thickness = 2 *) ImageData@ImageRotate@Image@Map[If[df[#] <= 2., 1., 0.] &,samplePt, {2}] 

Image looks like this.

enter image description here

Here goes a visualization of the 2D spiral mesh and the generated 19415$19415$ points on the Cartesian plane with aan Euclidean distance of utmost 2$2$ units from the spiral. CanOne can generate less points by choosing coarser (>0.8) sampling in Range[##, .8]. Code follows after the image.

enter image description here

Show[Graphics@{PointSize@Tiny, Orange,Point/@ (If[df[#] <= 2, #, Unevaluated[Sequence[]]] & /@ Flatten[samplePt,1])}, HighlightMesh[reg, Style[1, Opacity[.7], Red]]] 

Another way will be to simply take advantage of the CapForm primitives and get those rounded lines. I am using a transformation rule on the Graphics object generated by the PolarPlot function to change the default lines into a rounded one.

plot=PolarPlot[theta/2 Pi, {theta, 0, 20 Pi},Axes->None,PlotStyle->Black, PlotRange -> All]; plot/.Line[point_] :> {CapForm["Round"],Thickness[.03],Line[point]} 

enter image description here

Update: An accurate way to address the following requirement!

"I need to have this pattern also represented as a matrix"

  1. First discretize the 2D line plot of the spiral and form a region distance function based on that discrete curve.
  2. Sample a good number of points on the $\{x,y\}$ plane where the spiral lies.
  3. Use the region distance function to mark only those points which satisfy you trench thickness criterion.

Here is the commented code to generate the requested matrix:

reg=DiscretizeGraphics@plot;(* Step 1: Discretize 2D *) df = RegionDistance[reg]; (* Step 1: Distance function *) (* Step 3: Sample point but extend the bounding box by {-4, +4} *) samplePt=Outer[List, ##] & @@ (Range[##, .8] & @@@ (# + {-4, +4} &/@RegionBounds[reg])); (* Get your image matrix! TRENCH Thickness = 2 *) ImageData@ImageRotate@Image@Map[If[df[#] <= 2., 1., 0.] &,samplePt, {2}] 

Here goes a visualization of the 2D spiral mesh and the generated 19415 points on the Cartesian plane with a distance of utmost 2 units from the spiral. Can generate less points by choosing coarser sampling in Range[##, .8]. Code follows after the image.

enter image description here

Show[Graphics@{PointSize@Tiny, Orange,Point/@ (If[df[#] <= 2, #, Unevaluated[Sequence[]]] & /@ Flatten[samplePt,1])}, HighlightMesh[reg, Style[1, Opacity[.7], Red]]] 

Another way will be to simply take advantage of the CapForm primitives and get those rounded lines. I am using a transformation rule on the Graphics object generated by the PolarPlot function to change the default lines into a rounded one.

plot=PolarPlot[theta/2 Pi, {theta, 0, 20 Pi},Axes->None,PlotStyle->Black, PlotRange -> All]; plot/.Line[point_] :> {CapForm["Round"],Thickness[.03],Line[point]} 

enter image description here

Update: An accurate way to address the following requirement!

"I need to have this pattern also represented as a matrix"

  1. First discretize the 2D line plot of the spiral and form a region distance function based on that discrete curve.
  2. Sample a good number of points on the $\{x,y\}$ plane where the spiral lies.
  3. Use the region distance function to mark only those points which satisfy you trench thickness criterion.

Here is the commented code to generate the requested matrix:

reg=DiscretizeGraphics@plot;(* Step 1: Discretize 2D *) df = RegionDistance[reg]; (* Step 1: Distance function *) (* Step 3: Sample point but extend the bounding box by {-4, +4} *) samplePt=Outer[List, ##] & @@ (Range[##, .8] & @@@ (# + {-4, +4} &/@RegionBounds[reg])); (* Get your image matrix! TRENCH Thickness = 2 *) ImageData@ImageRotate@Image@Map[If[df[#] <= 2., 1., 0.] &,samplePt, {2}] 

Image looks like this.

enter image description here

Here goes a visualization of the 2D spiral mesh and the generated $19415$ points on the Cartesian plane with an Euclidean distance of utmost $2$ units from the spiral. One can generate less points by choosing coarser (>0.8) sampling in Range[##, .8]. Code follows after the image.

enter image description here

Show[Graphics@{PointSize@Tiny, Orange,Point/@ (If[df[#] <= 2, #, Unevaluated[Sequence[]]] & /@ Flatten[samplePt,1])}, HighlightMesh[reg, Style[1, Opacity[.7], Red]]] 
added 1486 characters in body
Source Link
PlatoManiac
  • 15k
  • 2
  • 44
  • 76

Another way will be to simply take advantage of the CapForm primitives and get those rounded lines. I am using a transformation rule on the Graphics object generated by the PolarPlot function to change the default lines into a rounded one.

PolarPlot[thetaplot=PolarPlot[theta/2 Pi, {theta, 0, 20 Pi}, Axes -> None>None,PlotStyle->Black, PlotRange -> Black]All]; plot/.Line[point_] :> {CapForm["Round"],Thickness[.03],Line[point]} 

enter image description here

Update: An accurate way to address the following requirement!

"I need to have this pattern also represented as a matrix"

  1. First discretize the 2D line plot of the spiral and form a region distance function based on that discrete curve.
  2. Sample a good number of points on the $\{x,y\}$ plane where the spiral lies.
  3. Use the region distance function to mark only those points which satisfy you trench thickness criterion.

Here is the commented code to generate the requested matrix:

reg=DiscretizeGraphics@plot;(* Step 1: Discretize 2D *) df = RegionDistance[reg]; (* Step 1: Distance function *) (* Step 3: Sample point but extend the bounding box by {-4, +4} *) samplePt=Outer[List, ##] & @@ (Range[##, .8] & @@@ (# + {-4, +4} &/@RegionBounds[reg])); (* Get your image matrix! TRENCH Thickness = 2 *) ImageData@ImageRotate@Image@Map[If[df[#] <= 2., 1., 0.] &,samplePt, {2}] 

Here goes a visualization of the 2D spiral mesh and the generated 19415 points on the Cartesian plane with a distance of utmost 2 units from the spiral. Can generate less points by choosing coarser sampling in Range[##, .8]. Code follows after the image.

enter image description here

Show[Graphics@{PointSize@Tiny, Orange,Point/@ (If[df[#] <= 2, #, Unevaluated[Sequence[]]] & /@ Flatten[samplePt,1])}, HighlightMesh[reg, Style[1, Opacity[.7], Red]]] 

Another way will be to simply take advantage of the CapForm primitives and get those rounded lines. I am using a transformation rule on the Graphics object generated by the PolarPlot function to change the default lines into a rounded one.

PolarPlot[theta/2 Pi, {theta, 0, 20 Pi}, Axes -> None,PlotStyle -> Black] /.Line[point_] :> {CapForm["Round"],Thickness[.03],Line[point]} 

enter image description here

Another way will be to simply take advantage of the CapForm primitives and get those rounded lines. I am using a transformation rule on the Graphics object generated by the PolarPlot function to change the default lines into a rounded one.

plot=PolarPlot[theta/2 Pi, {theta, 0, 20 Pi},Axes->None,PlotStyle->Black, PlotRange -> All]; plot/.Line[point_] :> {CapForm["Round"],Thickness[.03],Line[point]} 

enter image description here

Update: An accurate way to address the following requirement!

"I need to have this pattern also represented as a matrix"

  1. First discretize the 2D line plot of the spiral and form a region distance function based on that discrete curve.
  2. Sample a good number of points on the $\{x,y\}$ plane where the spiral lies.
  3. Use the region distance function to mark only those points which satisfy you trench thickness criterion.

Here is the commented code to generate the requested matrix:

reg=DiscretizeGraphics@plot;(* Step 1: Discretize 2D *) df = RegionDistance[reg]; (* Step 1: Distance function *) (* Step 3: Sample point but extend the bounding box by {-4, +4} *) samplePt=Outer[List, ##] & @@ (Range[##, .8] & @@@ (# + {-4, +4} &/@RegionBounds[reg])); (* Get your image matrix! TRENCH Thickness = 2 *) ImageData@ImageRotate@Image@Map[If[df[#] <= 2., 1., 0.] &,samplePt, {2}] 

Here goes a visualization of the 2D spiral mesh and the generated 19415 points on the Cartesian plane with a distance of utmost 2 units from the spiral. Can generate less points by choosing coarser sampling in Range[##, .8]. Code follows after the image.

enter image description here

Show[Graphics@{PointSize@Tiny, Orange,Point/@ (If[df[#] <= 2, #, Unevaluated[Sequence[]]] & /@ Flatten[samplePt,1])}, HighlightMesh[reg, Style[1, Opacity[.7], Red]]] 
Source Link
PlatoManiac
  • 15k
  • 2
  • 44
  • 76

Another way will be to simply take advantage of the CapForm primitives and get those rounded lines. I am using a transformation rule on the Graphics object generated by the PolarPlot function to change the default lines into a rounded one.

PolarPlot[theta/2 Pi, {theta, 0, 20 Pi}, Axes -> None,PlotStyle -> Black] /.Line[point_] :> {CapForm["Round"],Thickness[.03],Line[point]} 

enter image description here