|
-
Jul 13th, 2003, 01:34 AM
#1
Thread Starter
Frenzied Member
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)?
-
Jul 13th, 2003, 07:53 AM
#2
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:
import java.util.*;
/**
* A rotation about a line.
*
* The l ine is specified by a point (x,y,z) and a unit vector (a,b,c).
* Rotation (r) is in radians.
*/
public class Rotation extends Transformation
{
private double m[][];
public Rotation(double x, double y, double z,
double a, double b, double c,
double r)
{
double sin_r = Math.sin(r);
double cos_r = Math.cos(r);
double i = 1.0 - cos_r;
double a_a_i = a * a * i;
double b_b_i = b * b * i;
double c_c_i = c * c * i;
double a_b_i = a * b * i;
double a_c_i = a * c * i;
double b_c_i = b * c * i;
double a_sin_r = a * sin_r;
double b_sin_r = b * sin_r;
double c_sin_r = c * sin_r;
m = new double [3][3];
m[0][0] = a_a_i + cos_r;
m[1][0] = a_b_i - c_sin_r;
m[2][0] = a_c_i + b_sin_r;
m[0][1] = a_b_i + c_sin_r;
m[1][1] = b_b_i + cos_r;
m[2][1] = b_c_i - a_sin_r;
m[0][2] = a_c_i - b_sin_r;
m[1][2] = b_c_i + a_sin_r;
m[2][2] = c_c_i + cos_r;
}
public void transform(Coordinates coords)
{
if (coords == null) return;
double x = coords.x * m[0][0] + coords.y * m[0][1] + coords.z * m[0][2];
double y = coords.x * m[1][0] + coords.y * m[1][1] + coords.z * m[1][2];
double z = coords.x * m[2][0] + coords.y * m[2][1] + coords.z * m[2][2];
coords.x = x;
coords.y = y;
coords.z = z;
}
}
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|