PDL's OpenGL stuff can be displayed in a Tk window. How interactive it is, is debatable......you can rotate with left-click drag, and zoom in/out with a right-click drag. Here is an example. (Don't ask for too many answers from me. The OpenGL coordinate view-space is "relative" to the largest axis, NOT straight cartesian. It's hard to explain it's behavior, but when you try and plot, you will see what I mean. I just hacked this :-) )
#!/usr/bin/perl use warnings; use strict; use Tk; use PDL; use PDL::Graphics::TriD; use PDL::Graphics::TriD::Contours; use PDL::Graphics::TriD::GL; use PDL::Graphics::TriD::Tk; my $TriDW; # declare the graph object in main, defined in initializ +e my $MW = MainWindow->new(); my $bframe = $MW->Frame()->pack( -side => 'top', -fill => 'x' ); # This is the TriD Tk widget it is a Tk Frame widget and has all of th +e # attributes of a Frame $TriDW = $MW->Tk()->pack( -expand => 1, -fill => 'both'); # The exit button my $e_button = $bframe->Button( -text => "Exit", -command => sub { exit } )->pack( -side => 'right', -anchor => 'nw', -fill => 'y' ); # Sets a default focus style for viewport #setfocusstyle( 'Pointer' ); # This sets the graphic that will be displayed when the window is firs +t opened $e_button->bind( "<Configure>", [ sub { my $but = shift; Torusdemos(); $e_button->bind( "<Configure>", '' ); } ] ); $TriDW->MainLoop; sub Torusdemos { my ( $bh ) = @_; return unless defined $TriDW->{ GLwin }; my $graph; $graph = $TriDW->{ GLwin }->current_viewport->graph(); # define the graph object $graph = new PDL::Graphics::TriD::Graph(); $graph->default_axes(); my $data; my $s = 40; my $a = zeroes 2 * $s, $s / 2; my $t = $a->xlinvals( 0, 6.284 ); my $u = $a->ylinvals( 0, 6.284 ); my $o = 0.5; my $i = 0.1; my $v = $o + $i * sin $u; my $x = $v * sin $t; my $y = $v * cos $t; my $z = $i * cos( $u ) + $o * sin( 3 * $t ); # color $data = new PDL::Graphics::TriD::SLattice( [ $x, $y, $z ], [ 0.5 * ( 1 + sin $t ), 0.5 * ( 1 + cos $t ), 0.25 * ( 2 + cos( $u ) + sin( 3 * $t ) ) ] ); # black and white # $data = new PDL::Graphics::TriD::SLattice_S( [ $x, $y, $z ] ); $graph->add_dataseries( $data, 'Torus-demo' ); $graph->scalethings(); $TriDW->current_viewport()->delete_graph( $graph ); $TriDW->current_viewport()->graph( $graph ); $TriDW->refresh(); }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re: 3d for Perl? by zentara
in thread 3d for Perl? by iSina

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.