PointClass p1 = new PointClass(); PointClass p2 = new PointClass(); // Add data to points for test p1.PutCoords(34.481560, 41.515391); p2.PutCoords(34.702832, 41.795668); ILine lineForAngle = new Line(); IMeasurementTool measurementTool = new MeasurementToolClass(); measurementTool.ConstructByPoints(p1, p2); // Here we calculate distance between two points: (p1, p2) double distance = measurementTool.Distance; GeometryEnvironment geoEnv = new GeometryEnvironment(); IConstructAngle angleCalculator = (IConstructAngle)geoEnv; lineForAngle.PutCoords(p1, p2); // Here we calculate angle of line between (p1, p2) and the positive x-axis double angle = angleCalculator.ConstructLine(lineForAngle); // Convert radian to degree angle *= 180 / Math.PI; // = 51.709836807757121 Degree // Convert angle to azimuth (still degree) angle = 90 - angle; // = 38.290163192242879 // Here I give first point (p1), azimuth and distance to get p2 measurementTool.ConstructByPointDistAngle(p1, distance, angle); geoEnv = new GeometryEnvironment(); angleCalculator = (IConstructAngle)geoEnv; // I put p1 and result point of measurementTool which is a point lineForAngle.PutCoords(p1, measurementTool.ToPoint); // Now I have calculate angle between p1 and result of measurementTool angle = angleCalculator.ConstructLine(lineForAngle); angle *= 180 / Math.PI; // = 43.443603752680005 // first angle - result angle: // 51.709836807757121 - 43.443603752680005 = 8.266233055077116
Dear All,
I have 2 points which creates a line. I want to get angle of line and then draw another line with +30 degree. I can do it but I always get 7-10 degree more than actual angle.
I get distance between 2 points using IMeasurementTool.ConstructByPoints, then I get angle using IConstructAngle.ConstructLine. Here I have angle and distance between 2 points. Now, I'll give ConstructByPointDistAngle first point, distance and angle to get second point. Now I calculate angle between first point and result point of ConstructByPointDistAngle but I get angle with 8.266233055077116 degree difference.
I think I'm not convert degree to azimuth correctly. Any idea?
FYI: azimuth is degrees clockwise from north
Here is my working code with comment and Debug results. Red texts are debug results.
PointClass p1 = new PointClass(); PointClass p2 = new PointClass(); // Add data to points for test p1.PutCoords(34.481560, 41.515391); p2.PutCoords(34.702832, 41.795668); ILine lineForAngle = new Line(); IMeasurementTool measurementTool = new MeasurementToolClass(); measurementTool.ConstructByPoints(p1, p2); // Here we calculate distance between two points: (p1, p2) double distance = measurementTool.Distance; GeometryEnvironment geoEnv = new GeometryEnvironment(); IConstructAngle angleCalculator = (IConstructAngle)geoEnv; lineForAngle.PutCoords(p1, p2); // Here we calculate angle of line between (p1, p2) and the positive x-axis double angle = angleCalculator.ConstructLine(lineForAngle); // Convert radian to degree angle *= 180 / Math.PI; // = 51.709836807757121 Degree // Convert angle to azimuth (still degree) angle = 90 - angle; // = 38.290163192242879 // Here I give first point (p1), azimuth and distance to get p2 measurementTool.ConstructByPointDistAngle(p1, distance, angle); geoEnv = new GeometryEnvironment(); angleCalculator = (IConstructAngle)geoEnv; // I put p1 and result point of measurementTool which is a point lineForAngle.PutCoords(p1, measurementTool.ToPoint); // Now I have calculate angle between p1 and result of measurementTool angle = angleCalculator.ConstructLine(lineForAngle); angle *= 180 / Math.PI; // = 43.443603752680005 // first angle - result angle: // 51.709836807757121 - 43.443603752680005 = 8.266233055077116
Hi!
To the point of your problem.
You use the intricate algorithm. I think it's easier to use IConstructPoint.ConstructDeflection method with the negative value of the angle (in radians) and the necessary distance.
Thank you a-subbotin for introducing me IConstructPoint.
Well, I used it based on ArcObjects' Help but result point was not correct. I used IConstructPoint.ConstructAngleDistance but result X,Y is so large numbers! My X,Ys are longtitude,latitude and distance is meter. Do you know ConstructAngleDistance's unit?
Thanks
angle = 90 - angle;
to a-subbotin:
Sorry, I didn't get what to do. How can I make ConstructAngleDistance function to use longtitude, latitude and meter? Can you please explain more or give me example code?
Thank you
to Wayne_Whitley:
Thank you for your reply.
Unfortunately I can't use toolboxes. I should implement it using .NET code. If you could help me on ConstructAngleDistance, that would be great.
Actually I subtract 90 degrees; as you see:angle = 90 - angle;
but I don't get correct angle.
Thanks