Results 1 to 4 of 4
 01032012, 02:29 PM #1Member
 Join Date
 Jan 2012
 Posts
 3
 Rep Power
 0
Distance between a point and a rect
Hi guys. I need your help. I've a project to school that I need to find the distance between a point and a line without using the distance formula in R3.
I already have this:
Java Code:public static void main(String[] args){ int[] eq = {1,0,2,2,1,3}; //data from equation (x,y,z)=(x0,y0,z0)+k(a,b,c) eq={x0,y0,z0,a,b,c} int[] P = {1,1,2}; //point distance(P,eq); } public static void distance(int[] P, int[] r){ double [] x={r[0],r[3],0}; double [] y={r[1],r[4],0}; double [] z={r[2],r[5],0}; double [] omega={0,0,0}; double [] i={0,0,0}; double alpha_t = r[3]*(r[0])  r[4]*(r[1])  r[5]*(r[2]); double [] alpha={r[3],r[4],r[5],alpha_t}; omega[0]=alpha[0]*x[1]+alpha[1]*y[1]+alpha[2]*z[1]; omega[1]=alpha[0]*x[0]+alpha[1]*y[0]+alpha[2]*z[0]alpha[3]; omega[2]=omega[1]/omega[0]; i[0]=x[0]+x[1]*omega[2]; i[1]=y[0]+y[1]*omega[2]; i[2]=z[0]+z[1]*omega[2]; double dist_=Math.pow((P[0]i[0]), 2)+Math.pow((P[1]i[1]), 2)+Math.pow((P[2]i[2]), 2); double dist=Math.sqrt(dist_); System.out.println(dist); }
If someone could help me, I would be grateful.Last edited by branquinho; 01032012 at 07:20 PM.
 01032012, 06:41 PM #2
Re: Distance between a point and a rect
Ok, first off, could you modify your post to put the code inside [code][/code] tags so we can read it?
 01032012, 07:03 PM #3Member
 Join Date
 Jan 2012
 Posts
 3
 Rep Power
 0
 01042012, 11:11 AM #4Member
 Join Date
 Jan 2012
 Posts
 3
 Rep Power
 0
Similar Threads

How to find the edges/border of a rect? (java.awt)
By Naxix in forum New To JavaReplies: 4Last Post: 10172011, 08:09 PM 
Detect collision between two objects(rect and oval)?
By Naxix in forum Java AppletsReplies: 0Last Post: 10152011, 10:56 PM 
MouseEntered to rect
By g6pd in forum New To JavaReplies: 3Last Post: 03102011, 02:52 PM 
Finding distance from a point to a Rectangle2D.objecy
By busdude in forum New To JavaReplies: 0Last Post: 04022009, 09:00 PM
Bookmarks