0
$\begingroup$

How can I plot a truncated cube with size (sqrt(2)-1)? The code I am using is simply

PolyhedronData["TruncatedCube"]
$\endgroup$
1
  • 1
    $\begingroup$ And by size you mean what? $\endgroup$
    – Kuba
    Commented Jun 2, 2016 at 9:03

1 Answer 1

4
$\begingroup$

In case size means length of each edge:

edgeLength = PolyhedronData["TruncatedCube", "EdgeLengths"][[1]];

Graphics3D[
 GeometricTransformation[
  First @ PolyhedronData["TruncatedCube"],
  ScalingTransform[{1, 1, 1} (Sqrt[2] - 1)/edgeLength]
  ]
 ,
 Axes -> True
 ]

enter image description here

$\endgroup$
8
  • 2
    $\begingroup$ For people like moi who prefer to avoid the use of GeometricTransformation[]: Graphics3D[ MapAt[# (Sqrt[2] - 1)/edgeLength &, PolyhedronData["TruncatedCube", "Faces"], 1], Axes -> True] $\endgroup$ Commented Jun 2, 2016 at 10:26
  • $\begingroup$ @J.M. one could simply use Scale too. p.s. Why do you prefer to avoid GeometricTransformation? $\endgroup$
    – Kuba
    Commented Jun 2, 2016 at 10:28
  • $\begingroup$ What if I need the side of the cube to be sqrt(2)-1? $\endgroup$
    – randomal
    Commented Jun 2, 2016 at 10:31
  • 3
    $\begingroup$ Yes, but Scale[] is like GeometricTransformation[] too; in my usual applications, I often apply replacement rules to the coordinates, and GeometricTransformation[] does not often play nice with such replacements. Another point against it for me is that DiscretizeGraphics[] and BoundaryDiscretizeGraphics[] do not (currently) work with GeometricTransformation[] objects. $\endgroup$ Commented Jun 2, 2016 at 10:33
  • 2
    $\begingroup$ @albus, did you notice the scaling factor used in Kuba's and my snippet? Replace that. $\endgroup$ Commented Jun 2, 2016 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.