Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9170109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:58:17+00:00 2026-06-17T15:58:17+00:00

Let’s say I have @points[$number][$x][$y][$z][$color] and I just for debug purposes want them visualized

  • 0

Let’s say I have @points[$number][$x][$y][$z][$color] and I just for debug purposes want them visualized in 3D cube to better observe what I have. Typically I export them to *.txt and use R 3D plotting, but maybe there is easy way to do this in Perl?
It would be even better to have spheres with radius.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:58:18+00:00Added an answer on June 17, 2026 at 3:58 pm

    My answer: use OpenGL perl bindings

    I haven’t quite done an exact answer to your question but I’m sure you can adopt this code

    I haven’t done OpenGL before but it was a fun little evening project

    use OpenGL qw/ :all /;
    use constant ESCAPE => 27;
    # Global variable for our window
    my $window;
    my $CubeRot = 0;
    my $xCord = 1;
    my $yCord = 1;
    my $zCord = 0;
    my $rotSpeed = 0.02 ;
    ($width, $height) = (1366,768);
    @points = ( [ 30,40,40,[100,0,0]], #red
                [ 100,100,40,[0,100,0]], #green
                [ 100,10,60,[0,100,100]], #turquoise
                [ 200,200,100,[0,0,100]] #blue
                );
    sub reshape  {  
    
    glViewport(0, 0, $width, $height); # Set our viewport to the size of our window  
    glMatrixMode(GL_PROJECTION); # Switch to the projection matrix so that we can manipulate how our scene is viewed  
    glLoadIdentity(); # Reset the projection matrix to the identity matrix so that we don't get any artifacts (cleaning up)  
    gluPerspective(60, $width / $height, 1.0, 100.0); # Set the Field of view angle (in degrees), the aspect ratio of our window, and the new and far planes  
    glMatrixMode(GL_MODELVIEW); # Switch back to the model view matrix, so that we can start drawing shapes correctly  
    glOrtho(0, $width, 0, $height, -1, 1);   # Map abstract coords directly to window coords. 
      glScalef(1, -1, 1);           # Invert Y axis so increasing Y goes down. 
      glTranslatef(0, -h, 0);       # Shift origin up to upper-left corner. 
    
    }  
    sub keyPressed {
    
        # Shift the unsigned char key, and the x,y placement off @_, in
        # that order.
        my ($key, $x, $y) = @_;
        # If escape is pressed, kill everything.
        if ($key == ESCAPE) 
        { 
            # Shut down our window 
            glutDestroyWindow($window); 
    
            # Exit the program...normal termination.
            exit(0);                   
        }
    }
    
    sub InitGL {              
    
        # Shift the width and height off of @_, in that order
        my ($width, $height) = @_;
    
        # Set the background "clearing color" to black
        glClearColor(0.0, 0.0, 0.0, 0.0);
    
        # Enables clearing of the Depth buffer 
        glClearDepth(1.0);                    
    
        glDepthFunc(GL_LESS);         
        # Enables depth testing with that type
        glEnable(GL_DEPTH_TEST);              
    
        # Enables smooth color shading
        glShadeModel(GL_SMOOTH);      
    
        # Reset the projection matrix
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity;
        # Reset the modelview matrix
        glMatrixMode(GL_MODELVIEW);
    }
        sub display {  
        glClearColor(1.0,0.0,0.0,1.0); 
        glClear(GL_COLOR_BUFFER_BIT);
        glLoadIdentity;
    
        glTranslatef(0.0, 0.0, -5.0); # Push eveything 5 units back into the scene, otherwise we won't see the primitive  
        #glPushMatrix();
        #glRotatef($CubeRot, $xCord, $yCord, $zCord);
    
       # this is where the drawing happens, adjust glTranslate to match your coordinates
       # the centre is is 0,0,0
        for my $sphere ( @points ) {
            glPushMatrix();
            glColor3b( @{$sphere->[3]}) ;
            glRotatef($CubeRot, $xCord, $yCord, $zCord);
            glTranslatef($sphere->[0]/50 -2 ,$sphere->[1]/50 -2 ,$sphere->[2]/50 -2);
            glutWireSphere(1.0,24,24); # Render the primitive  
            glPopMatrix();
            }
        $CubeRot += $rotSpeed;
        glFlush; # Flush the OpenGL buffers to the window  
        }  
    
    # Initialize GLUT state
    glutInit;  
    
    # Depth buffer */  
    glutInitDisplayMode(GLUT_SINGLE);
    
    
    
    # The window starts at the upper left corner of the screen
    glutInitWindowPosition(0, 0);  
    
    # Open the window  
    $window = glutCreateWindow("Press escape to quit");
    
    # Register the function to do all our OpenGL drawing.
    glutDisplayFunc(\&display);  
    
    # Go fullscreen.  This is as soon as possible. 
    glutFullScreen;
    glutReshapeFunc(\&reshape);
    # Even if there are no events, redraw our gl scene.
    glutIdleFunc(\&display);
    
    # Register the function called when the keyboard is pressed.
    glutKeyboardFunc(\&keyPressed);
    
    # Initialize our window.
    InitGL($width, $height);
    
    # Start Event Processing Engine
    glutMainLoop;  
    
    return 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a table with a Color column. Color can have various
Let's say I have thousands of users and I want to make the passwords
Let's say I have a 1 GB text file and I want to read
Let's say you have a class library project that has any number of supplemental
Let's say I have a file foo.py, and within the file I want to
Let's say I have an Instant Messenger server using SignalR. I want to broadcast
Let's say I have a Person class with FirstName and LastName . I want
Let's say I have my own website, my own database and I want to
Let's say I have a method in java, which looks up a user in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.