Hi all,
Me again ;-) I am now pretty sure that this method should compute the point
beneath a street!
I need the method because I want to paint a vehicle in the right direction
beneath a street! Shown in the attachment.
Here "my" code:
public static double[] getPoint(
double[] x,double degree,
double distance) {
// compute from input degree , degree with + 90°
degree= (degree+90)%360;
double xdiff = Math.sin(Math.toRadians(degree)) * distance;
double ydiff = Math.cos(Math.toRadians(degree)) * distance;
return new double[]{x[0]+xdiff,x[1]+ydiff};
}
Here the test cases:
// case 1
test=getPoint( new double[]{0,0} ,0,100);
System.out.println(test[0]+" "+test[1]); //output (100,almost 0)
//case 2
test=getPoint( new double[]{0,0} ,90,100);
System.out.println(test[0]+" "+test[1]);//output (almost 0,-100)
//case 3
test=getPoint( new double[]{0,0} ,180,100);
System.out.println(test[0]+" "+test[1]);//output (-100,almost 0)
//case 4
test=getPoint( new double[]{0,0} ,270,100);
System.out.println(test[0]+" "+test[1]);//output (0,100)
In my opinion the results are correct! Has anybody any failures found?
Cheers,
Martin
-----Original Message-----
From: Martin Tomko [mailto:[email protected]]
Sent: Donnerstag, 8. April 2010 17:27
To: Martin; [email protected]; JTS Topology Suite Development;
geotools users
Subject: How to, calculate a Point given another point, a distance and a
angle
Hi Martin (1 = H., Andy,
I am not sure it is a good idea to cross post this on so many related
forums, but ok... :)
Martin, the problem with your use of Andy's code is that the arguments
to Math.sin (and other trigo functions) should be in radians, see:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html#sin%28double%29
Hope this helps,
Martin
P.S. I will also be curois about your traffic simulation
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users