I have developed an application in top of ArcGIS Desktop using Arcobjects C#.Net. Application will create a rectangle by connecting four known co-ordinates. I would need to adjust all four corners as orthogonal (90 degree). Is there any mathematical way to achieve this from four known co-ordinates? or Is there any straight forward method in Arcobjects to do this?
Asked
Active
Viewed 228 times
1
-
1Can you draw an example of the adjusted coordinates shape relative to / over the top of the original shape? – Creyke Sep 09 '18 at 07:11
-
You will have choose which corner will be stationary, then use some good old fashioned high-school trigonometry, however, if adjacent sides aren't the same length, then it wont be as easy as just straightening out one angel and applying the transformation to the rest, you will have to change lengths – TheGeneral Sep 09 '18 at 07:20
1 Answers
3
If you want to ensure the angles are 90 degrees, you will need to ensure the diagonals are of the same lenght. this means in your example the length(P1-P3) == lenght(P2-P4).
You can go with: midpoint = middle of (P1-P3). This is your centre point. Now move the dotted line parallel towards the midpoint. Now you have your adjusted P2 and P4, crossing the circle and dotted line.
in code:
static void Main(string[] args)
{
Point P1 = new Point() { X = 2, Y = 1 };
Point P2 = new Point() { X = 1.8, Y = 2.5 };
Point P3 = new Point() { X = 6, Y = 4 };
Point P4 = new Point() { X = 6.2, Y = 2.6 };
double distX13 = P3.X - P1.X;
double distY13 = P3.Y - P1.Y;
Point midP = new Point() { X = P1.X + distX13 / 2, Y = P1.Y + distY13 / 2 };
double lenght13 = Math.Sqrt(distX13 * distX13 + distY13 * distY13);
double a24 = Math.Atan2(P4.Y - P2.Y, P4.X - P2.X);
P2.X = midP.X - Math.Cos(a24) * lenght13 / 2;
P2.Y = midP.Y - Math.Sin(a24) * lenght13 / 2;
P4.X = midP.X + Math.Cos(a24) * lenght13 / 2;
P4.Y = midP.Y + Math.Sin(a24) * lenght13 / 2;
}

Aldert
- 4,209
- 1
- 9
- 23