0
Follow
0
View

We know the coordinates of A,B, the length of AC, the length of BC. Find the coordinates of point C. Note(the upper left corner is the starting point of the coordinate system)

dsqlvxin 注册会员
2023-02-28 05:51

NET to use functions from the Math class for square and square root operations :

double x1 = 0, y1 = 0; // A点坐标
double x2 = 3, y2 = 4; // B点坐标
double a = 5, b = 4; // AC边长和BC边长
double x3 = (Math.Pow(a, 2) - Math.Pow(b, 2) + Math.Pow(x2, 2) - Math.Pow(x1, 2)) / (2 * (x2 - x1));
double y3 = (Math.Pow(a, 2) - Math.Pow(b, 2) + Math.Pow(y2, 2) - Math.Pow(y1, 2)) / (2 * (y2 - y1));
Console.WriteLine("C点坐标为({0}, {1})", x3, y3);
dj7311 注册会员
2023-02-28 05:51
%!((MISSING)C_x, C_y)) .
< !- - - - - >
dyfdyfdyf 注册会员
2023-02-28 05:51

According to the triangle side length formula, we can calculate the $AB$side length squared $d^2$:

< 2 = ( x x < /span> < 2 + ( y y < /span> 2

Next, we can calculate the angle of $\angle ACB$according to the Law of cosine $\theta$:

cos θ A < C < 2 + B < C < 2 2 < / span > < / span > < / span > < span class = "MJXp - box" style = "margin - top: 0.9 em." > 2 × A C × B C

According to the definition of trigonometric functions, we can get $\angleB

cs86a1 注册会员
2023-02-28 05:51
double ax = double .Parse(Console.ReadLine()); Console. Write ("请输入A点的Y坐标:"); double ay = double .Parse(Console.ReadLine()); Console. Write ("请输入B点的X坐标:"); double bx = double .Parse(Console.ReadLine()); Console. Write ("请输入B点的Y坐标:"); double by = double .Parse(Console.ReadLine()); Console. Write ("请输入AC边长:"); double ac = double .Parse(Console.ReadLine()); Console. Write ("请输入BC边长:"); double bc = double .Parse(Console.ReadLine()); // 计算C点坐标 double cx = (ac * ac - bc * bc + bx * bx - ax * ax) / ( 2 * (bx - ax)); double cy = (ac * ac - cx * cx - ax * ax + ay * ay) / ( 2 * ay); // 输出结果 Console.WriteLine($"C点的坐标为 ({cx},{cy})"); } } .
< !- - - - - >
zed5801008 注册会员
2023-02-28 05:51

First, calculate the Angle θ between point A and point B, i.e. θ=arctan((y2-y1)/(x2-x1)).
Then, according to AC side length a and θ, the x-coordinate x3 of point C can be calculated, that is, x3=x1+a cosθ;
Similarly, according to the BC side length b and θ, the ordinate y3 of point C can be calculated, that is, y3=y1+b
sinθ. < br / > so, what are the coordinates of the point C(x3, y3) =(x1 + a < em > cosine theta, y1 + b < / em > sine theta).

dabule99 注册会员
2023-02-28 05:51

ac and BC known < br / > a, b known < br / > please coordinate(x, y) < br / > c(x - a1) ^ 2 +(y - a2) ^ 2 = ac ^ 2 < br / >(x - b1) ^ 2 +(y - b2) ^ 2 = BC ^ 2 < br / > two simultaneous work out x, y is fine.
Please take mine, thank you double x,y; < br / > < br / > 1-2(x - a1 + x - b1) +(x - a1 - x + b1)(y - a2 + b2) y(y - a2 - y + b2) = ac ^ 2 - < br / > get x, y relationship into 1 < br / > this time, Since all variables are known
rewrite
(x-a1)^2+(x-num)^2=ac^2
, then expand to get the value of x +_ sign select
, obviously there are two symmetric results
x,y has four combinations
, then we need to judge whether the length of the side is ac,bc is as If ac,bc this coordinate is suitable and can be output directly.
gives x,y

dskfepay 注册会员
2023-02-28 05:51

by Pythagorean theorem

ctnzwj 注册会员
2023-02-28 05:51

This answer quotes ChatGPT

Suppose the coordinate of point A is(xA, yA), the coordinate of point B is(xB, yB), the length of AC is c, the length of BC is d, and the coordinate of point C is(xC, yC).

according to the Pythagorean theorem, the AC ^ 2 =(xC - xA) ^ 2 +(yC - yA) ^ 2, BC ^ 2 =(xC - xB) ^ 2 +(yC - yB) ^ 2.

Transpose xC^2 and yC^2 in AC^2 and BC^2 to give the following two equations:

xC^2 - 2 xC xA + xA^2 + yC^2 - 2 yC yA + yA^2 = c^2

xC^2 - 2 xC xB + xB^2 + yC^2 - 2 yC yB + yB^2 = d^2

Subtract xC^2 and yC^2 from both equations to get:

-2 xC xA + xA^2 - 2 xC xB + xB^2 - 2 yC yA + yA^2 - 2 yC yB + yB^2 = c^2 - d^2

The above equation is simplified to give the following two equations:

xC = [(c^2 - d^2) +(xB^2 - xA^2) +(yB^2 - yA^2)] /(2(xB - xA))
yC = [(c^2 - d^2) +(yB^2 - yA^2) + 2 xC(xA - xB)] /(2(yB - yA))

Therefore, the coordinates of point C can be calculated by the above formula.

#include 
#include 

struct point {
    float x, y;
};

struct point calculate_C(struct point A, struct point B, float AC, float BC) {
    struct point C;
    float AB = sqrt(pow(B.x - A.x, 2) + pow(B.y - A.y, 2));
    float cosA = (pow(AC, 2) + pow(AB, 2) - pow(BC, 2)) / (2 * AC * AB);
    float sinA = sqrt(1 - pow(cosA, 2));
    C.x = A.x + AC * (B.x - A.x) / AB;
    C.y = A.y + AC * (B.y - A.y) / AB;
    float dx = (C.x - A.x) * cosA - (C.y - A.y) * sinA + A.x;
    float dy = (C.x - A.x) * sinA + (C.y - A.y) * cosA + A.y;
    C.x = dx;
    C.y = dy;
    return C;
}

int main() {
    struct point A = {2, 3};
    struct point B = {10, 5};
    float AC = 8.0623;
    float BC = 10.0499;
    struct point C = calculate_C(A, B, AC, BC);
    printf("C = (%.2f, %.2f)\n", C.x, C.y);
    return 0;
}


A struct point structure is used here to represent the coordinate points, and the calculate_C function is used to calculate the coordinates of point C. In the main function, coordinates A and B as well as the values of side lengths AC and BC can be set. In addition, calculate_C function can be called to calculate the coordinates of point C and print it out.

hainancyp 注册会员
2023-02-28 05:51

code:

using System;

public class Program
{
    public static void Main()
    {
        double x1 = 0;
        double y1 = 0;
        double x2 = 3;
        double y2 = 4;
        double d1 = 5;
        double d2 = 4;

        double x3 = (d1*d1 - d2*d2 + x2*x2 - x1*x1) / (2 * (x2 - x1));
        double y3 = Math.Sqrt(d1*d1 - (x3 - x1)*(x3 - x1)) + y1;

        Console.WriteLine("Point C is located at ({0}, {1})", x3, y3);
    }
}


bizhixiang 注册会员
2023-02-28 05:51

Python code is faster. For example, we know that the coordinate of point A is(1,2), the coordinate of point B is(5,6), and the side length of AC is 4, BC has a length of 5. According to the above method, we calculate the AB side length first, and then solve for the Cx and Cy coordinates. And finally, we determine the Cy sign depending on whether C is above or below A. The output result is: The coordinates of point C are:(2.6, 0.8)

import math

# 已知点A,B坐标和AC,BC边长
Ax, Ay = 1, 2
Bx, By = 5, 6
AC = 4
BC = 5

# 计算AB边长
AB = math.sqrt((Bx - Ax) ** 2 + (By - Ay) ** 2)

# 计算Cx坐标
Cx = (AC ** 2 - BC ** 2 + AB ** 2) / (2 * AB)

# 计算Cy坐标
Cy = math.sqrt(AC ** 2 - Cx ** 2)
if By > Ay:
    Cy = Ay + Cy
else:
    Cy = Ay - Cy

# 输出C点坐标
print("C点坐标为:({0}, {1})".format(Cx, Cy))