Rotating Pyramid
Author: Mike May, S.J.

This worksheet shows a pyramid that is rotated in 3 space

With minor modifications it is based on an applet written by
Lucio Ferrari, SM Pregassona, Switzerland.
Used with permission.

Show Altitude

Show Slant Height

Side Triangle

Edge Triangle

zRot = 0 rad (slider from 0 to 6.283185307179586, step 0.017453292519943295)
xRot = 0 rad (slider from 0 to 6.283185307179586, step 0.017453292519943295)
BasePts: {{{-1.0}, {-1.0}, {0.0}}, {{-1.0}, {1.0}, {0.0}}, {{1.0}, {1.0}, {0.0}}, {{1.0}, {-1.0}, {0.0}}}
yProjectionProportion = 0.5 (slider from 0 to 1, step 0.01)
RotedBasePts = Sequence(Rz[zRot] Rx[xRot] Element[BasePts, k], k, 1.0, Length[BasePts])
yProjectionAngle = 0.7853981633974483 rad (slider from 0 to 6.283185307179586, step 0.017453292519943295)
ProjMat: {{1.0, yProjectionProportion cos(yProjectionAngle), 0.0}, {0.0, yProjectionProportion sin(yProjectionAngle), 1.0}}
Rotx = 0 (slider from -5 to 5, step 0.1)
RotzMat: {{cos(zRot), sin(zRot), 0.0}, {-1.0 * 1.0 * 1.0 sin(zRot), cos(zRot), 0.0}, {0.0, 0.0, 1.0}}
RotyMat: {{cos(xRot), 0.0, sin(xRot)}, {0.0, 1.0, 0.0}, {-1.0 * 1.0 * 1.0 * 1.0 sin(xRot), 0.0, cos(xRot)}}
RotxMat: {{1.0, 0.0, 0.0}, {0.0, cos(Rotx), -1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 sin(Rotx)}, {0.0, sin(Rotx), cos(Rotx)}}
ProjRotBasePts = Sequence(ProjMat Element[RotedBasePts, k], k, 1.0, Length[RotedBasePts])
P0 = 0
ProjBasePt2d = Sequence((Element[Element[Element[ProjRotBasePts, k], 1.0], 1.0], Element[Element[Element[ProjRotBasePts, k], 2.0], 1.0]), k, 1.0, Length[ProjRotBasePts])
BaseSegLattice = Sequence(Sequence[Segment[Element[ProjBasePt2d, k], Element[ProjBasePt2d, l]], k, 1.0, Length[ProjBasePt2d]], l, 1.0, Length[ProjBasePt2d])
axDisp = 0 (slider from -3 to 3, step 0.1)
ayDisp = 0 (slider from -3 to 3, step 0.1)
ht = 2
A3d: {{axDisp}, {ayDisp}, {ht}}
A3dProj: ProjMat Rz[xRot] Rx[xRot] A3d
A3dImage: (Element[Element[A3dProj, 1.0], 1.0], Element[Element[A3dProj, 2.0], 1.0])
Edges2Vertex = Sequence(Segment[Element[ProjBasePt2d, k], A3dImage], k, 1.0, Length[ProjBasePt2d])
Sides2Vertex = Append(Sequence[Polygon[Element[ProjBasePt2d, k], Element[ProjBasePt2d, k + 1.0], A3dImage], k, 1.0, Length[ProjBasePt2d] - 1.0], Polygon[Element[ProjBasePt2d, 1.0], Element[ProjBasePt2d, Length[ProjBasePt2d]], A3dImage])
altBase3d: {{axDisp}, {ayDisp}, {0.0}}
altBaseProj: ProjMat Rz[xRot] Rx[xRot] altBase3d
altBase: (Element[Element[altBaseProj, 1.0], 1.0], Element[Element[altBaseProj, 2.0], 1.0])
alt = Segment(A3dImage, altBase)
MidPtEdge3: (Element[ProjBasePt2d, 3.0] + Element[ProjBasePt2d, 4.0]) / 2.0
slantHt = Segment(A3dImage, MidPtEdge3)
r = Segment(altBase, MidPtEdge3)
ShowAlt = true
ShowSH = true
STriangle, ST3side, ST2side, ST1side = Polygon(A3dImage, MidPtEdge3, altBase)
ShowST = false
ETriangle, ET2side, ET1side, ET3side = Polygon(A3dImage, altBase, Element[ProjBasePt2d, 3.0])
ShowET = false

Tool: Rz
Give Angle of z rotation
Input: t
Output: rotz

rotz: {{cos(t), sin(t), 0.0}, {-1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 sin(t), cos(t), 0.0}, {0.0, 0.0, 1.0}}

Tool: Rx
Give angle of x rotation
Input: t
Output: rotx

rotx: {{1.0, 0.0, 0.0}, {0.0, cos(t), sin(t)}, {0.0, -1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 * 1.0 sin(t), cos(t)}}

Tool: Cav
Cavalier projection (angle and factor)
Input: a, f
Output: Cav

Cav: {{1.0, 0.0}, {f cos(a), f sin(a)}, {0.0, 1.0}}

Tool: PP
Crea punti da lista di 2-vettori
Input: D
Output: D'

D: {{{1.0, 0.0}}, {{0.5972906806161636, 0.1664348903516518}}, {{-0.63, 0.1}}, {{-0.99, -0.1}}, {{0.02, -0.17}}, {{1.0, 0.0}}}
D' = Sequence((Element[Element[Element[D, k], 1.0], 1.0], Element[Element[Element[D, k], 1.0], 2.0]), k, 1.0, Length[D])

Tool: CX
Coordinata x
Input: E
Output: C_x

E: {{0.2051423187457533, 0.4093554777201233, -2.2358217632667}}
C_x = Element(Element[E, 1.0], 1.0)

Tool: CY
Coordinata y
Input: E
Output: C_y

E: {{0.2051423187457533, 0.4093554777201233, -2.2358217632667}}
C_y = Element(Element[E, 1.0], 2.0)

Tool: CZ
Coordinata z
Input: E
Output: C_z

E: {{0.2051423187457533, 0.4093554777201233, -2.2358217632667}}
C_z = Element(Element[E, 1.0], 3.0)

Tool: Assegna
Input: lista
Output: togli

lista: {{{4.990791389699066, 6.160139071075733, -2.92648046798742}}, {{4.369158108252163, 5.931579335429786, -3.486517521031252}}, {{4.42, 5.85, -4.35}}, {{5.11, 5.97, -4.86}}, {{5.91, 6.21, -4.64}}, {{6.23, 6.38, -3.86}}, {{5.82, 6.36, -3.09}}, {{4.99, 6.16, -2.93}}}
togli = Sequence(Element[Element[lista, k], 1.0], k, 1.0, Length[lista])

Tool: Copia
Input: lista
Output: copia

lista: {{{3.749399456654644E-33, 6.123233995736766E-17, -1.0}}, {{-6.123233995736766E-17, 7.498798913309288E-33, -1.0}}, {{-1.124819836996393E-32, -6.123233995736766E-17, -1.0}}, {{6.123233995736766E-17, -1.499759782661858E-32, -1.0}}, {{-6.123233995736766E-17, -1.0, -1.224646799147353E-16}}, {{1.0, -1.224646799147353E-16, -1.224646799147353E-16}}, {{1.83697019872103E-16, 1.0, -1.224646799147353E-16}}, {{-1.0, 2.449293598294706E-16, -1.224646799147353E-16}}, {{-1.124819836996393E-32, -1.83697019872103E-16, 1.0}}, {{1.83697019872103E-16, -2.249639673992786E-32, 1.0}}, {{3.374459510989179E-32, 1.83697019872103E-16, 1.0}}, {{-1.83697019872103E-16, 4.499279347985573E-32, 1.0}}, {{6.123233995736766E-17, 1.0, 2.449293598294706E-16}}, {{-1.0, 1.224646799147353E-16, 2.449293598294706E-16}}, {{-1.83697019872103E-16, -1.0, 2.449293598294706E-16}}, {{1.0, -2.449293598294706E-16, 2.449293598294706E-16}}}
copia = Sequence(Element[lista, k], k, 1.0, Length[lista])