TransWikia.com

How do I discretize Line objects

Mathematica Asked by Dunlop on August 16, 2021

I have a polygon object that I wish to discretize.

e.g.

points0 = {{0, 0}, {1, 2}, {1, 0}, {0, 0}}
DiscretizeRegion[Line[points0]]

My goal is to increase the number of points between the edges using internal Mathematica functions. I have tried using Polygon, BoundaryDiscretize reigion and other functions but can’t seem to get just the edge meshed. Any help would be greatly appreciated.

2 Answers

You can specify the maximum cell measures using the option MaxCellMeasure:

enter image description here

DiscretizeRegion[Line[points0], MaxCellMeasure -> {"Length" -> .1}] (* or *)

DiscretizeRegion[Line[points0], MaxCellMeasure -> {1 -> .1}]    

enter image description here

Use MaxCellMeasure -> {"Length" -> .5} to get

enter image description here

Correct answer by kglr on August 16, 2021

Given points0 we want to insert points so that the original interval between two point is split into n intervals:

n = 2;
points0 = {{0, 0}, {1, 2}, {1, 0}, {0, 0}};
tmp = Table[#[[1]] + i (#[[2]] - #[[1]])/n, {i, 0, n - 1}] & /@ 
  Partition[points0, 2, 1]
newpts=Append[Flatten[tmp, 1], points0[[-1]]]

enter image description here

Answered by Daniel Huber on August 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP