// povray +I ./eulerwinkel.pov -geometry 1600x1200
// RPY == ZY'X''
// ZYZ
// ZY'X''
// ZXZ
#include "math.inc"
#include "strings.inc"
#include "colors.inc"
// povray-Achsen http://www.povray.org/documentation/view/3.6.1/15/
// x -> links nach rechts
// y -> von unten nach oben
// z -> tiefe
// **********
// *
// * Globals
// *
// **********
#declare Ansicht = 1;
#declare Konvention = 3; // 1 = ZY'X'' // 2 = ZYZ // 3 = ZXZ
#declare Schritt = 3; // 0, 1, 2, 3
#declare Vektor_Teilung = 1;
// * Vektor_Durchmesser
#declare Vektor_Durchmesser = 0.1;
// * Vektor_Schrift
#declare Vektor_Schrift = "Schrift/DejaVuSans.ttf"
#declare Winkel_Vektor_Radius = 2.5;
#declare Abstand = 40;
#if (Ansicht = 1)
#declare Kameraposition = <0.25 * Abstand, 0.25 * Abstand, -0.75 * Abstand>;
#end
#if (Ansicht = 2)
#declare Kameraposition = <0, 0, -33>;
#end
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#macro Flacher_Pfeil(
Farbe
)
prism {
linear_sweep
linear_spline
0, // sweep the following shape from here ...
0.2, // ... up through here
8, // the number of points making up the shape ...
<0,0>, <1.,0.5>, <1.,0.2>, <4,0.2>, <4,-0.2>, <1.,-0.2>, <1.,-0.5>, <0,0>
translate <-2,-0.1,0>
rotate <0,-90,0>
pigment { Farbe }
}
#end
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#macro Koordinatenachsen(
X, Y, Z, X_Farbe, Y_Farbe, Z_Farbe )
union {
object {
Vektor(<0,0,0>, Y, "Y", "", Y_Farbe) // povray x-Achse
}
object {
Vektor(<0,0,0>, Z, "Z", "", Z_Farbe) // povray y-Achse
// Vektor_Index(<0,0,0>, <0,5,0>, "L", "0")
}
object {
Vektor(<0,0,0>, X, "X", "", X_Farbe) // povray z-Achse (und invertiert)
}
object {
sphere {
<0,0,0>, Vektor_Durchmesser
pigment { Gray50 }
}
}
}
#end // Koordinatenachsen
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#macro Koordinatenachsen_ZYX(
Z_Winkel, Y_Winkel, X_Winkel,
X_Farbe, Y_Farbe, Z_Farbe
)
#local lBasis_X = z;
#local lBasis_X = vrotate( lBasis_X, <Y_Winkel, 0, 0> );
#local lBasis_X = vrotate( lBasis_X, <0, -1* Z_Winkel, 0> );
// #local lBasis_X = vrotate( lBasis_X, < 0, 0, X_Winkel> );
#local lBasis_Y = x;
#local lBasis_Y = vrotate( lBasis_Y, < Y_Winkel, 0, 0> );
// #local lBasis_Y = vrotate( lBasis_Y, < 0, 0, X_Winkel> );
#local lBasis_Y = vrotate( lBasis_Y, <0, -1* Z_Winkel, 0> );
#local lBasis_Y = vaxis_rotate(lBasis_Y, lBasis_X, -1 * X_Winkel);
#local lBasis_Z = y;
#local lBasis_Z = vrotate( lBasis_Z, < Y_Winkel, 0, 0> );
// #local lBasis_Z = vrotate( lBasis_Z, < 0, 0, X_Winkel> );
#local lBasis_Z = vrotate( lBasis_Z, < 0, -1* Z_Winkel, 0> );
#local lBasis_Z = vaxis_rotate(lBasis_Z, lBasis_X, -1 * X_Winkel);
Koordinatenachsen(-2.5 * lBasis_X, 2.5 * lBasis_Y, 2.5 * lBasis_Z,
X_Farbe, Y_Farbe, Z_Farbe)
#end // Koordinatenachsen_ZYX
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#macro Koordinatenachsen_ZYZ(
Z1_Winkel, Y_Winkel, Z2_Winkel,
X_Farbe, Y_Farbe, Z_Farbe
)
#local lBasis_X = z;
#local lBasis_Y = x;
#local lBasis_Z = y;
// Um Z rotieren
#local lBasis_X = vaxis_rotate(lBasis_X, lBasis_Z, -1 * Z1_Winkel);
#local lBasis_Y = vaxis_rotate(lBasis_Y, lBasis_Z, -1 * Z1_Winkel);
// Um Y rotieren
#local lBasis_X = vaxis_rotate(lBasis_X, lBasis_Y, Y_Winkel);
#local lBasis_Z = vaxis_rotate(lBasis_Z, lBasis_Y, Y_Winkel);
// um Z rotieren
#local lBasis_X = vaxis_rotate(lBasis_X, lBasis_Z, Z2_Winkel);
#local lBasis_Y = vaxis_rotate(lBasis_Y, lBasis_Z, Z2_Winkel);
Koordinatenachsen(-2.5 * lBasis_X, 2.5 * lBasis_Y, 2.5 * lBasis_Z,
X_Farbe, Y_Farbe, Z_Farbe)
#end // Koordinatenachsen_ZYX
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#macro Koordinatenachsen_ZXZ(
Z1_Winkel, X_Winkel, Z2_Winkel,
X_Farbe, Y_Farbe, Z_Farbe
)
#local lBasis_X = z;
#local lBasis_Y = x;
#local lBasis_Z = y;
// Um Z rotieren
#local lBasis_X = vaxis_rotate(lBasis_X, lBasis_Z, -1 * Z1_Winkel);
#local lBasis_Y = vaxis_rotate(lBasis_Y, lBasis_Z, -1 * Z1_Winkel);
// Um Y rotieren
#local lBasis_Y = vaxis_rotate(lBasis_Y, lBasis_X, X_Winkel);
#local lBasis_Z = vaxis_rotate(lBasis_Z, lBasis_X, X_Winkel);
// um Z rotieren
#local lBasis_X = vaxis_rotate(lBasis_X, lBasis_Z, Z2_Winkel);
#local lBasis_Y = vaxis_rotate(lBasis_Y, lBasis_Z, Z2_Winkel);
Koordinatenachsen(-2.5 * lBasis_X, 2.5 * lBasis_Y, 2.5 * lBasis_Z,
X_Farbe, Y_Farbe, Z_Farbe)
#end // Koordinatenachsen_ZYX
//////////////////////////////////////////////////////////////////////////////
//
// Makro zum Zeichnen eines Vektors als runde, pfeilartige Struktur samt
// Beschriftung.
//
//////////////////////////////////////////////////////////////////////////////
// Gobale Variablen
// * Vektor_Teilung
// * Kameraposition
// * Vektor_Staerke
// * Vektor_Schrift
#macro Vektor_Komplett(
Ort,
Vektor_Koordinaten,
Beschriftung
Index
Beschriftung_Seite
Farbe
// Farbe #1
// Farbe #2
)
#local Laenge = vlength(Vektor_Koordinaten);
#local Laenge_Cone = Laenge - (10.*Vektor_Durchmesser);
#local Vektor_Cone = Vektor_Koordinaten * (Laenge_Cone / Laenge);
#local Kamerarichtung_Text = Kameraposition - (Ort + Vektor_Cone); // Richtung der Kamera, vom Text aus (Näherungsweise)
#local Normalvektor_Text = -1.2 * Beschriftung_Seite * vnormalize(vcross(<Kamerarichtung_Text.x, 0, Kamerarichtung_Text.z>, Vektor_Koordinaten));
#local Ortsvektor_Text = Ort + Vektor_Cone + Normalvektor_Text;
// braucht es nicht // #local Kamerarichtung_Text = Kameraposition-(Ort+Vektor_Cone+Normalvektor_Text); // Richtung der Kamera, vom Text aus
// Überschlagswinkel
// Normalvektor aus Kamerarichtung und Vektor in Relation zu x-z-Ebene ergibt den Winkel zur y-Achse
// Winkel zwischen Normalvektor xy-Ebene und Vektor
#local lText_xy_Angle = VAngleD(x, <Kameraposition.x,0,Kameraposition.z>);
//#local lText_xz_Angle = VAngleD(vcross(x,z), Kameraposition);
//#local lText_yz_Angle = VAngleD(vcross(y,z), Kameraposition);
#local lText = text {
ttf Vektor_Schrift,
Beschriftung, 0.025, 0
}
#local lIndex = text {
ttf Vektor_Schrift,
Index, 0.025, 0
}
union {
#if (Laenge_Cone > 0.)
union { // Pfeil
cylinder {
<0, 0, 0>, Vektor_Cone, Vektor_Durchmesser
}
cone {
Vektor_Cone, 3.*Vektor_Durchmesser, Vektor_Koordinaten, 0.
}
translate Ort
}
#else
#if(Laenge > Vektor_Durchmesser)
cone {
<0,0,0>, 3.*Vektor_Durchmesser, Vektor_Koordinaten, 0.
translate Ort
}
#else
sphere {
<0,0,0>, Vektor_Durchmesser
translate Ort
}
#end
#end
union { // Text
// box { <0,0,0.1>, <2,1,1> }
object {
lText
translate x*-1* max_extent(lText).x/2 // hack -> center text
translate y*-1* max_extent(lText).y/2 // hack -> center text
}
#if ( strlen(Index) != 0 )
object {
lIndex
scale 0.67
translate y * max_extent(lText).y * (-0.5 + -0.2)
translate x * (max_extent(lText).x/2 + 0.1)
}
#end // if
//rotate <lText_xz_Angle, 0, 0>
rotate <0, lText_xy_Angle-90, 0>
translate Ortsvektor_Text
}
pigment {
color Farbe
}
}
#end // Vektor_Komplett
//////////////////////////////////////////////////////////////////////////////
//
// Makro zum Zeichnen eines Vektors als runde, pfeilartige Struktur samt
// Beschriftung.
//
//////////////////////////////////////////////////////////////////////////////
#macro Vektor(
Ort,
Vektor_Koordinaten,
Beschriftung,
Index,
Farbe
)
Vektor_Komplett(Ort, Vektor_Koordinaten, Beschriftung, Index, 1, Farbe)
#end
//////////////////////////////////////////////////////////////////////////////
//
// Makro zum Zeichnen eines Vektors als runde, pfeilartige Struktur samt
// Beschriftung. Mit invertierter Beschriftungsseite.
//
//////////////////////////////////////////////////////////////////////////////
#macro Vektor_Invert(
Ort,
Vektor_Koordinaten,
Beschriftung,
Index,
Farbe
)
Vektor_Komplett(Ort, Vektor_Koordinaten, Beschriftung, Index, -1, Farbe)
#end
//////////////////////////////////////////////////////////////////////////////
//
// Makro zum Zeichnen eines Winkelvektors als runde, pfeilartige Struktur samt
// Beschriftung.
//
//////////////////////////////////////////////////////////////////////////////
// Gobale Variablen
// * Vektor_Teilung
// * Kameraposition
// * Vektor_Staerke
// * Vektor_Schrift
// * Winkel_Vektor_Radius
#macro Winkel_Vektor_Komplett(
Zentrum,
Winkel,
Winkel_Start,
Winkel_Hochachse,
Winkel_Neigung,
Beschriftung
Index
Beschriftung_Seite // TODO
Farbe
// Farbe #1
// Farbe #2
)
#local lWinkel = Winkel - sgn(Winkel) * 10;
#local Laenge_Cone = (5.*Vektor_Durchmesser); // kürzer als der gerade Vektor
#local lPfeil = union { // Pfeil
object {
Segment_of_Torus(Winkel_Vektor_Radius, Vektor_Durchmesser, lWinkel)
}
cone { // Pfeilspitze
0, 0, z * sgn(Winkel) * Laenge_Cone, 3.*Vektor_Durchmesser
//rotate y * -10
translate x * Winkel_Vektor_Radius
rotate y * Winkel
}
rotate x * 90
rotate z * Winkel_Start
rotate x * Winkel_Neigung
rotate y * Winkel_Hochachse
}
// Text
#local lText_Winkel = Winkel + Winkel_Start - sgn(Winkel) * 10.;
#local lText_Basis_Vektor = <cos(radians(lText_Winkel)),sin(radians(lText_Winkel)), 0> * Winkel_Vektor_Radius;
#local lText_Ortho_Basis_Vektor = vnormalize(vcross(lText_Basis_Vektor, z)); // Senkrecht zum Basisvektor und in der Kreisbogenebene
#local lText_Basis_Vektor = vaxis_rotate(lText_Basis_Vektor, x, Winkel_Neigung);
#local lText_Basis_Vektor = vaxis_rotate(lText_Basis_Vektor, y, Winkel_Hochachse);
#local lText_Ortho_Basis_Vektor = vaxis_rotate(lText_Ortho_Basis_Vektor, x, Winkel_Neigung);
#local lText_Ortho_Basis_Vektor = vaxis_rotate(lText_Ortho_Basis_Vektor, y, Winkel_Hochachse);
#local lText_Kamerarichtung = Kameraposition - (Zentrum + lText_Basis_Vektor); // Richtung der Kamera, vom Text aus (Näherungsweise)
#local lText_Kamerarichtung = vnormalize(lText_Kamerarichtung);
#local lText_Ortho_Vektor = vnormalize(vcross(<lText_Kamerarichtung.x, 0, lText_Kamerarichtung.z>, lText_Ortho_Basis_Vektor)) * -1.2; // TODO magic number
// #local lText_Ortho_Vektor = 0;
#local lText_Vektor = lText_Basis_Vektor + lText_Ortho_Vektor;
//#local Normalvektor_Text = -1.2 * Beschriftung_Seite * vnormalize(vcross(<Kamerarichtung_Text.x, 0, Kamerarichtung_Text.z>, Vektor_Koordinaten));
// Ziel
// maximaler Winkel zur xz-Ebene ausgehend vom Basisvektor
// Text zeigt in Kamerarichtung
// liegt in einer Ebene die Senkrecht auf auf der Kreisbogenebene steht
// #local lKreisbogen_Ortho_Vektor =
#local lText_xy_Angle = VAngleD(x, <Kameraposition.x,0,Kameraposition.z>);
#local lBeschriftung = text {
ttf Vektor_Schrift,
Beschriftung, 0.025, 0
}
#local lIndex = text {
ttf Vektor_Schrift,
Index, 0.025, 0
}
#local lText = union { // Text
#if ( strlen(Beschriftung) != 0 )
object {
lBeschriftung
translate x*-1* max_extent(lBeschriftung).x/2 // hack -> center text
translate y*-1* max_extent(lBeschriftung).y/2 // hack -> center text
}
#end // if
#if ( strlen(Index) != 0 )
object {
lIndex
scale 0.67
translate y * max_extent(lBeschriftung).y * (-0.5 + -0.2)
translate x * (max_extent(lBeschriftung).x/2 + 0.1)
}
#end // if
rotate y * (lText_xy_Angle-90)
translate lText_Vektor
}
union {
/* Debug
cylinder {
lText_Vektor
lText_Basis_Vektor
0.1
}
cylinder {
lText_Basis_Vektor
(lText_Basis_Vektor + lText_Ortho_Basis_Vektor)
0.1
}
cylinder {
lText_Basis_Vektor
(lText_Basis_Vektor + <lText_Kamerarichtung.x, 0, lText_Kamerarichtung.z>)
0.1
}
*/
object {
lPfeil
}
object {
lText
}
translate Zentrum
pigment {
color Farbe
}
}
#end // Winkel_Vektor_Komplett
//////////////////////////////////////////////////////////////////////////////
//
// Segment eines Torus liegt in der xz-Ebene, Startpunkt ist die x-Achse
//
// http://www.f-lohmueller.de/pov_tut/all_shapes/shapes3_20d.htm
//
//////////////////////////////////////////////////////////////////////////////
#macro Segment_of_Torus ( R_major, R_minor, Segment_Angle)
#local D = 0.00001;
#if (Segment_Angle < 0)
#local Negativ_Flag = 1;
#local Segment_Angle = -Segment_Angle;
#else
#local Negativ_Flag = 0;
#end
#if (Segment_Angle > 360)
#local Segment_Angle = mod(Segment_Angle,360);
#end
intersection{
torus { R_major, R_minor }
#if (Segment_Angle > 180)
merge {
#end // use union!
box{ <-1,-1,0>,<1,1,1>
scale< R_major+R_minor+D,R_minor+D,R_major+R_minor+D>
} // end of box
box{ <-1,-1,-1>,<1,1,0>
scale< R_major+R_minor+D,R_minor+D,R_major+R_minor+D>
rotate< 0,-Segment_Angle,0 >
} // end of box
#if (Segment_Angle > 180)
}
#end // end of union, if union is used!
#if (Negativ_Flag = 0) rotate<0, Segment_Angle,0>
#end
} // end of intersection
#end // ----------------- end of macro Segment_of_Torus()
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#macro Konvention_ZYX (Schritt)
union
{
#if(Schritt > 0)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
30, // Winkel,
-90, // Winkel_Start,
0, // Winkel_Hochachse,
90, // Winkel_Neigung,
"α", // Beschriftung
"", // Index
1, // Beschriftung_Seite
SlateBlue
)
}
#end
#if(Schritt > 1)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
60, // Winkel,
0, // Winkel_Start,
60, // Winkel_Hochachse,
0, // Winkel_Neigung,
"β", // Beschriftung
"", // Index
1, // Beschriftung_Seite
LimeGreen
)
}
#end
#if(Schritt > 2)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
30, // Winkel,
0, // Winkel_Start,
-30, // Winkel_Hochachse,
60, // Winkel_Neigung,
"γ", // Beschriftung
"", // Index
1, // Beschriftung_Seite
OrangeRed
)
}
#end
object {
#if(Schritt = 3)
Koordinatenachsen_ZYX(30, 60, -30,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 2)
Koordinatenachsen_ZYX(30, 60, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 1)
Koordinatenachsen_ZYX(30, 0, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 0)
Koordinatenachsen_ZYX(0, 0, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
translate <x_offset,y_offset,0>
}
}
#end // Konvention_ZYX
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#macro Konvention_ZYZ(Schritt)
union
{
#if(Schritt > 0)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
30, // Winkel,
-90, // Winkel_Start,
0, // Winkel_Hochachse,
90, // Winkel_Neigung,
"α", // Beschriftung
"", // Index
1, // Beschriftung_Seite
SlateBlue
)
}
#end
#if(Schritt > 1)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
60, // Winkel,
0, // Winkel_Start,
60, // Winkel_Hochachse,
0, // Winkel_Neigung,
"β", // Beschriftung
"", // Index
1, // Beschriftung_Seite
LimeGreen
)
}
#end
#if(Schritt > 2)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
-30, // Winkel,
90, // Winkel_Start,
-30, // Winkel_Hochachse,
-30, // Winkel_Neigung,
"γ", // Beschriftung
"", // Index
1, // Beschriftung_Seite
SlateBlue
)
}
#end
object {
#if(Schritt = 3)
Koordinatenachsen_ZYZ(30, 60, -30,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 2)
Koordinatenachsen_ZYZ(30, 60, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 1)
Koordinatenachsen_ZYZ(30, 0, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 0)
Koordinatenachsen_ZYZ(0, 0, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
translate <x_offset,y_offset,0>
}
}
#end // Konvention_ZYZ
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#macro Konvention_ZXZ(Schritt)
union
{
#if(Schritt > 0)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
30, // Winkel,
-90, // Winkel_Start,
0, // Winkel_Hochachse,
90, // Winkel_Neigung,
"α", // Beschriftung
"", // Index
1, // Beschriftung_Seite
SlateBlue
)
}
#end
#if(Schritt > 1)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
-30, // Winkel,
90, // Winkel_Start,
150, // Winkel_Hochachse,
0, // Winkel_Neigung,
"β", // Beschriftung
"", // Index
-1, // Beschriftung_Seite
OrangeRed
)
}
#end
#if(Schritt > 2)
object
{
Winkel_Vektor_Komplett(
<x_offset,y_offset,0>, // Zentrum,
60, // Winkel,
0, // Winkel_Start,
60, // Winkel_Hochachse,
60, // Winkel_Neigung,
"γ", // Beschriftung
"", // Index
1, // Beschriftung_Seite
SlateBlue
)
}
#end
object {
#if(Schritt = 3)
Koordinatenachsen_ZXZ(30, 30, -60,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 2)
Koordinatenachsen_ZXZ(30, 30, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 1)
Koordinatenachsen_ZXZ(30, 0, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
#if(Schritt = 0)
Koordinatenachsen_ZXZ(0, 0, 0,
OrangeRed, LimeGreen, SlateBlue) // Farbe
#end
translate <x_offset,y_offset,0>
}
}
#end // Konvention_ZXZ
// *******
// *
// * MAIN
// *
// *******
#declare x_offset = 0;
#declare y_offset = -1;
#declare Transparenz = 1- 0.5;
// povray +I ./test.pov -geometry 1600x1200
global_settings {
charset utf8
}
background {
White
}
camera {
orthographic
angle 20
location Kameraposition
look_at <0, .1, 0>
}
light_source {
Kameraposition
color White * 1.5 shadowless
parallel
point_at<0, 0, 0>
}
//
// Koordinatenachsen
//
object {
Vektor(<x_offset+3,y_offset,0>, <2.5,0,0>, "y", "", Gray50) // povray x-Achse
}
object {
Vektor(<x_offset,y_offset+3,0>, <0,2.5,0>, "z", "", Gray50) // povray y-Achse
// Vektor_Index(<0,0,0>, <0,5,0>, "L", "0")
}
object {
Vektor_Invert(<x_offset,y_offset,-3>, <0,0,-2.5>, "x", "", Gray50) // povray z-Achse (und invertiert)
}
#if (Konvention = 3) // ZYZ
Konvention_ZXZ(Schritt)
#end
#if (Konvention = 2) // ZYZ
Konvention_ZYZ(Schritt)
#end
#if (Konvention = 1) // ZYX // RPY
object {
Konvention_ZYX(Schritt)
}
#end