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

  • Home
  • SEARCH
  • 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 6655009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:27:38+00:00 2026-05-26T01:27:38+00:00

I been messing around with drawing 3D Objects in C# using PaintEventArgs.Graphics and the

  • 0

I been messing around with drawing 3D Objects in C# using PaintEventArgs.Graphics and the following code

public void findPoints()
{
    xp1 = (p1x * 1000) / (p1z + 1000);
    xp2 = (p2x * 1000) / (p2z + 1000);
    xp3 = (p3x * 1000) / (p3z + 1000);
    xp4 = (p4x * 1000) / (p4z + 1000);
    yp1 = (p1y * 1000) / (p1z + 1000);
    yp2 = (p2y * 1000) / (p2z + 1000);
    yp3 = (p3y * 1000) / (p3z + 1000);
    yp4 = (p4y * 1000) / (p4z + 1000);
    xp5 = (p5x * 1000) / (p5z + 1000);
    xp6 = (p6x * 1000) / (p6z + 1000);
    xp7 = (p7x * 1000) / (p7z + 1000);
    xp8 = (p8x * 1000) / (p8z + 1000);
    yp5 = (p5y * 1000) / (p5z + 1000);
    yp6 = (p6y * 1000) / (p6z + 1000);
    yp7 = (p7y * 1000) / (p7z + 1000);
    yp8 = (p8y * 1000) / (p8z + 1000);
}

private void drawCube(PaintEventArgs e)
{
    /*
     * Bottom left = 1
     * Bottom right = 2
     * Top right = 3
     * Top left = 4
     * Back Top left = 5
     * Back Top right = 6
     * Back bottom right = 7
     * Back bottom left = 8
     */
    findPoints();
    Graphics g = e.Graphics;
    g.DrawLine(pen, xp1, yp1, xp2, yp2);
    g.DrawLine(pen, xp2, yp2, xp3, yp3);
    g.DrawLine(pen, xp3, yp3, xp4, yp4);
    g.DrawLine(pen, xp4, yp4, xp1, yp1);
    g.DrawLine(pen, xp1, yp1, xp8, yp8);
    g.DrawLine(pen, xp8, yp8, xp7, yp7);
    g.DrawLine(pen, xp7, yp7, xp2, yp2);
    g.DrawLine(pen, xp2, yp2, xp7, yp7);
    g.DrawLine(pen, xp7, yp7, xp6, yp6);
    g.DrawLine(pen, xp6, yp6, xp3, yp3);
    g.DrawLine(pen, xp3, yp3, xp6, yp6);
    g.DrawLine(pen, xp6, yp6, xp5, yp5);
    g.DrawLine(pen, xp5, yp5, xp4, yp4);
    g.DrawLine(pen, xp4, yp4, xp5, yp5);
    g.DrawLine(pen, xp5, yp5, xp8, yp8);
}

The issue comes when I try to manipulate the cube drawn using Matrix.Rotate and nested for loops.

For example I can make a circle with the following code.

private void rotateCube(PaintEventArgs e, int value)
{
    Matrix myMatrix = new Matrix();
    myMatrix.Rotate(value, MatrixOrder.Append);
    e.Graphics.Transform = myMatrix;
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
    for (int x = 0; x < 360; ++x)
    {
        rotateCube(e, x);
        Thread.Sleep(3);
        drawCube(e);
    }
}

When I use that code to draw a circle I only get the bottom right part of the circle because the origin of the screen (and center of the circle) is 0,0 on a co-ordinate system or the top left of the monitor. My question is… is there a way to move the origin of the screen or circle to perhaps the middle of the screen?

  • 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-05-26T01:27:39+00:00Added an answer on May 26, 2026 at 1:27 am

    Multiply your rotation matrix by a translation matrix.

    Keep in mind that moving the camera by (100px,100px) is equivalent to moving your model by (-100px,-100px).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been messing around with the following code to add each node in an
I have been messing around with writing some stored procedures in .NET code with
I've been messing around with jQuery plugin code and I'm trying to put all
I've been messing around with this for some time. I recently started using the
I've been messing around with the Graphics class to draw some things on a
I've been messing around with using Node.js and CouchDB. What I want to be
I've been messing around with the free Digital Mars Compiler at work (naughty I
I've been messing around with Python over the weekend and find myself pretty much
I've been messing around with the SQLite Designer in Visual Studio 2008 and I
I've been messing around a bit with various solutions to what I would see

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.