您的位置:程序门 -> .net技术 -> c#



简单的计算问题?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


简单的计算问题?
发表于:2007-03-03 21:52:08 楼主
各位高手:
    有一个很简单的数学题,由于长时间没接触数学公式,现在基本上忘记了。在编程过程中,有一个计算的问题给卡注了,手头还没公式,一时不知如何算,麻烦各位高手帮忙一下。
    已知a,b两点,a点(x1,y1)、b点(x2,y2),有一点c,bc距离=100,角abc为@,如何计算出c点坐标?
    谢谢
发表于:2007-03-03 22:10:591楼 得分:0
设   要求点c的座标为(x3,y3)按余弦定理可知:

ac^2=bc^2+ab^2-2cos(@)*bc*ab

通过2次求欧氏几何空间中两点距离可列出两个这样的方程,它们是,ac   和bc

ac=math.sqrt((y3-y1)^2+(x3-x1)^2)...k1
bc=100=math.sqrt((y3-y2)^2+(x3-x2)^2)...k2

两个未知数两个方程,如果最后不是线性相关,那有解,看样子也应该有解,我线性代数不好,说错的地方见见谅,希望可以给楼主一个参考!

注,由于   没有查阅有关公式,以上所给的定理公式不敢保证就是正确的。
发表于:2007-03-04 00:16:412楼 得分:0
自己用几何图形画出来,计算就是了。
发表于:2007-03-04 08:38:593楼 得分:0
感谢projectdd的支持,能有哪位能给出更具体计算方法吗?
发表于:2007-03-04 08:56:424楼 得分:0
正弦定理是
a/sina=b/sinb=c/sinc=2r
其中r是三角形外接圆半径
发表于:2007-03-04 11:56:005楼 得分:0
///   <summary>
///   计算两点间的角度
///   </summary>
///   <param   name= "aorigin "> 原点坐标 </param>
///   <param   name= "apoint "> 参考点坐标 </param>
///   <returns> 返回两点间的角度 </returns>
private   double   pointtoangle(point   aorigin,   point   apoint)
{
        if   (apoint.x   ==   aorigin.x)
                if   (apoint.y   >   aorigin.y)
                        return   math.pi   *   0.5;
                else   return   math.pi   *   1.5;
        else   if   (apoint.y   ==   aorigin.y)
                if   (apoint.x   >   aorigin.x)
                        return   0;
                else   return   math.pi;
        else
        {
                double   result   =   math.atan((aorigin.y   -   apoint.y)   /  
                        (aorigin.x   -   apoint.x));
                if   ((apoint.x   <   aorigin.x)   &&   (apoint.y   >   aorigin.y))
                        return   result   +   math.pi;
                else   if   ((apoint.x   <   aorigin.x)   &&   (apoint.y   <   aorigin.y))
                        return   result   +   math.pi;
                else   if   ((apoint.x   >   aorigin.x)   &&   (apoint.y   <   aorigin.y))
                        return   result   +   2   *   math.pi;
                else   return   result;
        }
}   /*   pointtoangle   */

private   point   calc(point   a,   point   b,   int   bc,   double   abc)
{
        double   d   =   pointtoangle(b,   a);
        return   new   point(
                (int)(math.cos(d   -   abc)   *   (bc))   +   b.x,
                (int)(math.sin(d   -   abc)   *   (bc))   +   b.y
        );
}

private   void   button1_click(object   sender,   eventargs   e)
{
        point   a   =   new   point(40,   40);
        point   b   =   new   point(100,   90);
        point   c   =   calc(a,   b,   100,   (1d   /   4d)   *   math.pi);
        graphics   vgraphics   =   graphics.fromhwnd(handle);
        vgraphics.drawline(pens.blue,   a,   b);
        vgraphics.drawline(pens.red,   a,   c);
        vgraphics.drawline(pens.green,   c,   b);
        vgraphics.drawstring( "a ",   font,   brushes.black,   0f   +   a.x,   0f   +   a.y);
        vgraphics.drawstring( "b ",   font,   brushes.black,   0f   +   b.x,   0f   +   b.y);
        vgraphics.drawstring( "c ",   font,   brushes.black,   0f   +   c.x,   0f   +   c.y);
}


快速检索

最新资讯
热门点击