Results 1 to 2 of 2

Thread: Calc 3d dot.

  1. #1

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    Arrow Calc 3d dot.

    I have a camera holding x, y, z and horizontal angle and vertical angle. I also have a coordinate (x,y,z) where i want to draw a dot.
    How do i draw this dot on a 2d picturebox (how do i calculate where it should be drawn)?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  2. #2
    pathfinder NotLKH's Avatar
    Join Date
    Apr 2001
    Posts
    2,397
    Generally speaking, I use the X,Y coordinate of an X,Y,Z Triple, plus some aesthetically pleasing fudge factor.


    BTW, You might find the following useful:

    Originally posted by NotLKH
    Sorry, I have'nt responded for a while.

    Guv- Thanks for the code. It looked potentially useful, but I thought trying to convert physical measurements to longi & latitude measurements might be a little daunting.

    After searching thru Many pages of "Rotational Matrices" inet articles, Great if I just stepped out of My Matrix college class yesterday, and all explaining the theory, with no applied examples, I stumbled over this, which is rotating a point around a 3d line's unit vector:

    VB Code:
    1. import java.util.*;
    2. /**
    3. * A rotation about a line.
    4. *
    5. * The l ine is specified by a point (x,y,z) and a unit vector (a,b,c).
    6. * Rotation (r) is in radians.
    7. */
    8. public class Rotation extends Transformation
    9. {
    10. private double m[][];
    11. public Rotation(double x, double y, double z,
    12. double a, double b, double c,
    13. double r)
    14. {
    15. double sin_r = Math.sin(r);
    16. double cos_r = Math.cos(r);
    17. double i = 1.0 - cos_r;
    18. double a_a_i = a * a * i;
    19. double b_b_i = b * b * i;
    20. double c_c_i = c * c * i;
    21. double a_b_i = a * b * i;
    22. double a_c_i = a * c * i;
    23. double b_c_i = b * c * i;
    24. double a_sin_r = a * sin_r;
    25. double b_sin_r = b * sin_r;
    26. double c_sin_r = c * sin_r;
    27. m = new double [3][3];
    28. m[0][0] = a_a_i + cos_r;
    29. m[1][0] = a_b_i - c_sin_r;
    30. m[2][0] = a_c_i + b_sin_r;
    31. m[0][1] = a_b_i + c_sin_r;
    32. m[1][1] = b_b_i + cos_r;
    33. m[2][1] = b_c_i - a_sin_r;
    34. m[0][2] = a_c_i - b_sin_r;
    35. m[1][2] = b_c_i + a_sin_r;
    36. m[2][2] = c_c_i + cos_r;
    37. }
    38. public void transform(Coordinates coords)
    39. {
    40. if (coords == null) return;
    41. double x = coords.x * m[0][0] + coords.y * m[0][1] + coords.z * m[0][2];
    42. double y = coords.x * m[1][0] + coords.y * m[1][1] + coords.z * m[1][2];
    43. double z = coords.x * m[2][0] + coords.y * m[2][1] + coords.z * m[2][2];
    44. coords.x = x;
    45. coords.y = y;
    46. coords.z = z;
    47. }
    48. }

    I'm not into Java yet, but this was perfectly understandable, and I retrofitted it to my app.

    ThinkTank: Thats a good example for 3d X,Y,Z Translocation. You should try getting some rotation in there!

    Thanks all!...

Posting Permissions

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



Click Here to Expand Forum to Full Width