Advertisement
Guest User

Untitled

a guest
May 28th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. lX = RandomVariate[UniformDistribution[{-0.4, 0.4}], {1000}];
  2. lY = RandomVariate[UniformDistribution[{-0.2, 0.2}], {1000}];
  3. lZ = RandomVariate[UniformDistribution[{-0.2, 0.2}], {1000}];
  4. lPoints = Thread[{lX,lY,lZ}];
  5.  
  6. g = Graphics3D[{Opacity[.09], EdgeForm[Opacity[.1]], Polygon[#,
  7. VertexColors -> Table[Hue[RandomReal[]], {Length[#]}]] & /@
  8. Cases[Normal[ExampleData[{"Geometry3D", "Cow"}]],
  9. Polygon[x_, ___] :> x, {0, Infinity}]}, Lighting -> "Neutral",
  10. ImageSize -> 400, Axes -> True];
  11.  
  12. Show[g, ListPointPlot3D[lPoints]]
  13.  
  14. side[{P_, Q_, R_, ___}, X_] := Det@Differences[{X, P, Q, R}];
  15. insideQ[polyhedron_, point_] := And @@ Positive[side[#, point] & /@ polyhedron];
  16. pg = Graphics3D[Point[lPoints,
  17. VertexColors -> (insideQ[polygonCoords, #] & /@
  18. lPoints /. {True -> Red,
  19. False -> Directive[Opacity[0.5], Blue]})], Axes -> True];
  20.  
  21. reg = BoundaryDiscretizeGraphics[g]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement