# The below section should do the math right. my $pi = 3.14159265358979; #my $pi = 4*atan2(1,1); sub deg_to_rad { ($_[0]/180) * $pi;} sub rad_to_deg { ($_[0]/$pi) * 180; } sub calc_quatcam { my $camx = shift; my $camy = shift; print "\nRad X:Y\t $camx : $camy\n"; # my $qx = rad_to_deg(acos($camx)); # my $qy = rad_to_deg(asin($camy)); my $qx = rad_to_deg($camx); my $qy = rad_to_deg($camy); print "\nRadian X:Y\t $qx : $qy\n"; print "Total: " . ($qx + $qy) . "\n"; $qx = ($qx * 2);# + 90.0; $qy = ($qy * 2);# + 90.0; my @calc_cam = ($qx, $qy); # print "\nQuat X:Y\t $qx : $qy\n"; return @calc_cam; } # Read in from the Hash. The function that reads from # the file returns an anon Array, so I have to access # as a scalar, then turn it into an Array. my $can_ori = $gff_files{Cameras}{$num}{Orientation}; @cam_ori = @$can_ori; my $cam_ori1 = @cam_ori[0]; # X-orientation my $cam_ori2 = @cam_ori[1]; # Always 0 my $cam_ori3 = @cam_ori[2]; # Always 0 my $cam_ori4 = @cam_ori[3]; # Y-orientation # Debugging print-out print "Orientation:\n\t$cam_ori1\n\t$cam_ori2\n\t$cam_ori3\n\t$cam_ori4\n\n"; # The orientation values are stored as radians, so # calc_quatcam returns the degree equivalent, or should... my @cam_quats = calc_quatcam($cam_ori1, $cam_ori4); my $qx = @cam_quats[0]; my $qy = @cam_quats[1];