I am trying to adapt the solution here, which places text in 3D on the xy plane, so that the text can be placed in any orientation. So, I wrapped it in three Rotate
statements, first by tilt around the x axis, then by elevation around the y-axis, then by longitude around the z-axis. However, this rotation happens after the text has been placed, away from the center of the axes. Trying to put the Rotation statements inside the meat of the function runs into the problem that I cannot tell from where the x and y coefficients are deriving so as to manipulate them using Rotate
. Anyway, the original is
xyText[str_, scaling_: 1, location_: {0, 0, 0}] :=
Module[{mesh =
DiscretizeGraphics[Text[Style[str, FontFamily -> "Times"]], _Text,
MaxCellMeasure -> 0.2]},
Join[{EdgeForm[]},
MeshPrimitives[mesh,
2] /. {x_?NumberQ,
y_?NumberQ} :> (scaling {x, y, 0} + location), {Black},
MeshPrimitives[BoundaryMesh[mesh],
1] /. {x_?NumberQ,
y_?NumberQ} :> (scaling {x, y, 0} + location)]]
and my inadequate adaptation is
ClearAll[xyText]
xyText[str_, scaling_: 1, location_: {0, 0, 0}, longitude_,
elevation_, tilt_] :=
Module[{mesh =
DiscretizeGraphics[Text[Style[str, FontFamily -> "Times"]], _Text,
MaxCellMeasure -> 0.2]}, Rotate[
Rotate[
Rotate[
Join[{EdgeForm[]},
MeshPrimitives[mesh,
2] /. {x_?NumberQ,
y_?NumberQ} :> (scaling {x, y, 0} + location)
, {Black},
MeshPrimitives[BoundaryMesh[mesh],
1] /. {x_?NumberQ,
y_?NumberQ} :> (scaling {x, y, 0} + location)],
tilt, {1, 0, 0}], elevation, {0, 1, 0}], longitude, {0, 0, 1}]]
The objective is for the yellow and the red "Dodecahedron" texts to intersect each other in this:
meshedSol =
Graphics3D[{Antialiasing -> True, Yellow, Opacity[.8],
PolyhedronData["Dodecahedron", "Faces"],
xyText["Dodecahedron", 0.2, {1, 1, 1}, 0, 0, 0],
Red, xyText["Dodecahedron", 0.2, {1, 1, .9}, 0, 0, \[Pi]/2]},
ViewPoint -> {-2, -2, 2}]
But instead, the red one is rotated after having been placed.
Update:
I gathered that x and y come from MeshPrimitives, so I made that 3D and wove in rotation matrices. Till we get a more elegant answer, I moved the result to be an answer.
Comments
Post a Comment