Closed Thread
Results 1 to 2 of 2

Thread: something i'm trying... but got a math problem i think (may be hard/complex)

  1. #1
    Join Date
    May 2009
    Location
    Belgium
    Posts
    1,881
    Rep Power
    24

    something i'm trying... but got a math problem i think (may be hard/complex)

    Heylo!

    i want to display 3D objects on a JPanel, or make it look like it's 3D, by changing the points of a certain shape... maybe that sounded a bit complex but here's a video of what I quickly punched together today (don't mention the bugs ):



    obviously i'm using x,y, and z.


    Now assume: i drop the Y factor, just x and Z AND I will only move my mouse horizontally.
    So if i move my mouse to the right, a point drawn should move to the right, but at the same time the z should lower(which isn't visible, due to 2D screens). Think of it like a point on a circle. if the point goes to the right or left, it also goes up or down.

    Now i'm looking for a formula which lets me calculate that when i move my mouse 100px to the right, how much i should increase/decrease the x value, and how much i should decrease/increase the z-value. It's probably something with cos and sin, but i can't find it.. Any smart person that could help me? (2z = circle's diameter me thinks)
    currently i don't do that, so at the bottom of my frame, in the 3th textfield i display the distance between point A & B .. that should normally be pretty constant

    It's just a JPanel basicly where i draw lines on
    Code:
     for (Point point : points) {
                for (Point neighbor : point.getNeighbors()) {
                    if (neighbor.getMaster() == point)
                        g.drawLine((int) point.getX(), (int) point.getY(), (int) neighbor.getX(), (int) neighbor.getY());
                }
            }
    i'm using a 'master point' for each point so the same line doesn't get drawn multiple times. in the example i use 3 points:
    master of A = C
    master of B = A
    master of C = B

    so even though C will look at A because it's his neighbour, it hasn't got the authoroty(C isn't the master of A) to draw a line between him and point A. something i learned from my networking class for a broadcasting algorythm


    PS(Where did the [highlight=java] tag go to?)

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    May 2009
    Location
    Belgium
    Posts
    1,881
    Rep Power
    24

    Re: something i'm trying... but got a math problem i think (may be hard/complex)

    Okay, got it, Can't believe i didn't think of this last night. My brain probably went to bed early
    It's like this


    i know z, and dX is the amount of px i moved my mouse to the right.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. problem to multiplication complex number
    By aimmh in forum Visual Basic Programming
    Replies: 1
    Last Post: 10-02-2010, 01:46 PM
  2. A Math Problem
    By Guest in forum The Lounge
    Replies: 11
    Last Post: 09-15-2010, 05:47 AM
  3. More of a Math Problem
    By Zer033 in forum C and C++
    Replies: 3
    Last Post: 06-19-2010, 12:50 PM
  4. NP-Hard problem
    By gk_manutd in forum General Programming
    Replies: 1
    Last Post: 01-23-2009, 09:41 AM
  5. Math.Cos problem
    By chemart in forum C# Programming
    Replies: 3
    Last Post: 01-16-2008, 01:46 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts