#include "math.inc"
#include "strings.inc"
#include "colors.inc"
//////////////////////////////////////////////////////////////////////////////
//
// Chaotic globals
//
//////////////////////////////////////////////////////////////////////////////
#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 = 12;
#declare Kameraposition = <0.2 * Abstand, 0.25 * Abstand, -0.75 * Abstand>;
//////////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////////
#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
//////////////////////////////////////////////////////////////////////////////
//
// 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
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// 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(-2.5 * z, 3.5 * x, 5 * y,
LimeGreen, Gray50, Blue) // Farbe
box{
<2, -1, 6>, <-2, 1, -6>
pigment {
OrangeRed transmit Transparenz
}
}