##################################################################
# Modul für Paare, Tupel, etc Plotter-Skriptes in Pstricks
#
# VERSION 3 Arbeitsversion
# Letzte Aenderung: 10.01.2012
##################################################################
use POSIX qw /floor ceil/;
use Math::Trig;
use strict;
use warnings;

my $texthier = "";

sub settexthier {
	my ($text) = @_;
	$texthier = $text;
}

sub gettexthier { return $texthier; }

sub textanhaengen {
	my ($text) = @_;
	$texthier = $texthier . $text;
}

sub klammer {
	my ($x) = @_;

	my $text = "{" . $x . "}";
	textanhaengen($text);
}

sub paar {
	my ( $x, $y ) = @_;
	if ( ( $x ne "ERROR" ) && ( $y ne "ERROR" ) && ( $x ne "" ) && ( $y ne "" ) ) {
		paarohneminmax( $x, $y );

		if ( ( istzahl($x) == 1 ) && ( istzahl($y) == 1 ) ) {
			minmax( $x, $y, $x, $y );
		}
		if ( getknoten() == 1 ) {
			if ( get3dzeichnen() == 1 ) { }
			else { knotensetzen( "\\pnode", $x, $y, "" ); }
		}
	}
}

sub paarohneminmax {
	my ( $x, $y ) = @_;

	my $text;

	$text = sprintf( "(%s,%s)", $x, $y );

	if ( $text =~ /([e!]+)/ ) {
		$text = sprintf( "(%s,%s)",
			nachkommastellen( $x, 4 ),
			nachkommastellen( $y, 4 ) );
	}
	textanhaengen($text);
}

sub tupel {
	my ( $x1, $y1, $x2, $y2 ) = @_;
	settexthier("");
	paar( $x1, $y1 );
	paar( $x2, $y2 );
}

sub vier {
	my ( $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4 ) = @_;
	settexthier("");
	paar( $x1, $y1 );
	paar( $x2, $y2 );
	paar( $x3, $y3 );
	paar( $x4, $y4 );

}

sub drei {
	my ( $x1, $y1, $x2, $y2, $x3, $y3 ) = @_;
	settexthier("");
	paarohneminmax( $x1, $y1 );
	paarohneminmax( $x2, $y2 );
	paarohneminmax( $x3, $y3 );
}

sub tripel {
	my ( $x, $y, $z ) = @_;

	my $text;

	if ( get3dpstricks() == 1 ) { tripelohneminmax( $x, $y, $z ) }
	else { paar( x3d( $x, $y, $z ), y3d( $x, $y, $z ) ); }

	minmax3d( $x, $y, $z, $x, $y, $z );

	if ( getknoten() == 1 ) {
		knotensetzen( "\\pnode", $x, $y, $z );
	}

}

sub tripelohneminmax {
	my ( $x, $y, $z ) = @_;
	my $text;
	$text = "(" . $x . "," . $y . "," . $z . ")";
	textanhaengen($text);
}

1;
