I am posting the same code found at an earlier question, although the concept here is totally different.
The following code corresponds to a building-shaped structure.
w = 100;
l = 200;
h = 30;
m = 70;
backwall = {{0, l, 0}, {w, l, 0}, {w, l, h}, {0, l, h}};
side1 = {{0, 0, 0}, {0, 0, h}, {0, l, h}, {0, l, 0}};
side2 = {{w, 0, 0}, {w, 0, h}, {w, l, h}, {w, l, 0}};
floor = {{0, 0, 0}, {w, 0, 0}, {w, l, 0}, {0, l, 0}};
top = {{0, 0, h}, {w, 0, h}, {w, l, h}, {0, l, h}};
front = {{0, 0, 0}, {w, 0, 0}, {w, 0, h}, {0, 0, h}};
leftRoof = {{0, 0, h}, {w/2, 0, m}, {w/2, l, m}, {0, l, h}};
rightRoof = {{w, 0, h}, {w/2, 0, m}, {w/2, l, m}, {w, l, h}};
roofBack = {{w, l, h}, {w/2, l, m}, {0, l, h}};
roofFront = {{w, 0, h}, {w/2, 0, m}, {0, 0, h}};
building = {backwall, side1, side2, floor, front, leftRoof, rightRoof,roofBack, roofFront};
figure =Graphics3D[{Opacity[0.5],Style[Polygon[building,VertexColors -> Map[0.5 + #[[3]]/80 &, building, {2}]],Lighting -> {{"Ambient", White}}]}, Boxed -> False,RotationAction -> "Clip"];
data = RandomReal[60, {100, 3}];
data1 = RandomReal[60, {100, 3}];
redPoints = Graphics3D[{Opacity[0.4], PointSize -> Large,Style[Point[#], Blue]} & /@ data, Boxed -> False,RotationAction -> "Clip"];
bluePoints =Graphics3D[{Opacity[0.4], PointSize -> Large,Style[Point[#], Red]} & /@ data1, Boxed -> False,RotationAction -> "Clip"];
Show[{figure, redPoints, bluePoints}]
and upon evaluation it produces:
I have 10000 points that need placing, some with coordinates inside the building while the remaining are outside (like the ones circled above).
I have the following two questions:
How can I omit the points that are not within the building?
How do I fill the entire building with points?
Having tried a few things this morning, I still couldn't get it to work as I want so any help is appreciated.
Comments
Post a Comment