KIKI... 2022-11-24 17:20 采纳率: 83.3%
浏览 3
已结题

关于#c##的问题:我想知道怎么才能返回resultP的值,然后这个值是有resultP.x和resultP.y的现在运行是返回空值

我想知道怎么才能返回resultP的值,然后这个值是有resultP.x和resultP.y的
现在运行是返回空值

namespace ConsoleApp2
{
    class Point
    {
        public double x;
        public double y;
    }
}
namespace ConsoleApp2
{
    class QFJH:AbstractCalculation
    {
        public override Point Crosscal(Point pa, Point pb, double a, double b)
        {
            Point resultP= new Point();
            resultP.x = (pa.x * (1 / Math.Tan(b)) + pb.x * Math.Tan(a) - pa.y + pb.y) / ((1 / Math.Tan(a) + (1 / Math.Tan(b))));
            resultP.y = (pa.y * (1 / Math.Tan(b)) + pb.y * Math.Tan(a) + pa.x - pb.x) / ((1 / Math.Tan(a) + (1 / Math.Tan(b))));
            
            return resultP;
        }
    }
}

调用代码

           Point paa= new Point();
            paa.x = 1.0;
            paa.y = 1.0;
            Point pbb=new Point();
            pbb.x = 5.5;
            pbb.y = 6.6;
            double aa = 45;
            double bb = 63;
            Point resultPP = new Point();
            //角度前方交会计算
            AbstractCalculation ac = new QFJH();
            resultPP=ac.Crosscal(paa,pbb,aa,bb);

  • 写回答

3条回答 默认 最新

  • CSDN专家-showbo 2022-11-24 18:16
    关注

    没问题啊,完整代码是什么

    using System;
    namespace ConsoleApp2
    {
        class Point
        {
            public double x;
            public double y;
        }
        class AbstractCalculation
        {
            public virtual Point Crosscal(Point pa, Point pb, double a, double b)
            {
                throw new Exception("TODO");
            }
        }
        class QFJH : AbstractCalculation
        {
            public override Point Crosscal(Point pa, Point pb, double a, double b)
            {
                Point resultP = new Point();
                resultP.x = (pa.x * (1 / Math.Tan(b)) + pb.x * Math.Tan(a) - pa.y + pb.y) / ((1 / Math.Tan(a) + (1 / Math.Tan(b))));
                resultP.y = (pa.y * (1 / Math.Tan(b)) + pb.y * Math.Tan(a) + pa.x - pb.x) / ((1 / Math.Tan(a) + (1 / Math.Tan(b))));
    
                return resultP;
            }
        }
        class Program
        {
            static void Main(string[] args)
            {
                Point paa = new Point();
                paa.x = 1.0;
                paa.y = 1.0;
                Point pbb = new Point();
                pbb.x = 5.5;
                pbb.y = 6.6;
                double aa = 45;
                double bb = 63;
                Point resultPP = new Point();
                //角度前方交会计算
                AbstractCalculation ac = new QFJH();
                resultPP = ac.Crosscal(paa, pbb, aa, bb);
    
                Console.WriteLine($"x:{resultPP.x} x:{resultPP.y}");
                Console.ReadKey();
            }
        }
    }
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 12月2日
  • 已采纳回答 11月24日
  • 修改了问题 11月24日
  • 创建了问题 11月24日

悬赏问题

  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持