• 每日总结


    今天完成小学期的第四个任务,只是用函数实现空间几何的部分算法,并无太多难点。代码:

    #include <iostream>
    #include <iomanip>
    using namespace std;
    class Point
    {
    public:
    double x;
    double y;
    double z;
    Point (){};
    };
    void A1()
    {
    Point a,b;
    cout<<"输入a,b两点的坐标:"<<endl;
    cin>>a.x >>a.y>>a.z >>b.x >>b.y>>b.z ;
    cout<<"直线为:(x-"<<a.x <<")/("<<b.x <<"-"<<a.x <<")=(y-"<<a.y <<")/("<<b.y <<"-"<<a.y <<")=z-"<<a.z <<")/("<<b.z <<"-"<<a.z <<")"<<endl;
    cout<<endl;
    };
    void B1()
    {
    double A1,A2,B1,B2,C1,C2,D1,D2;
    cout<<"假设空间方程为:A1x+B1y+C1z+D1=0,A2x+B2y+C2z+D2=0,输入A1,B1,C1,A2,B2,C:"<<endl;
    cin>>A1>>B1>>C1>>D1>>A2>>B2>>C2>>D2;
    double E,F,G;
    E=B1*C2-B2*C1;F=A2*C1-A1*C2;G=A1*B2-A2*B1;
    double x,y;
    x=((B1*D2-B2*D1)/(A1*B2-A2*B1));
    y=((A1*D2-A2*D1)-(A2*B1-A1*B2));
    cout<<setw(2)<<"直线方程为:(x-"<<x<<")/"<<E<<"=(y-"<<y<<")/"<<F<<"=z/"<<G<<endl;
    }
    void C1()
    {
    Point a,b;
    cout<<"输入a,b,两点的坐标:"<<endl;
    cin>>a.x >>a.y >>a.z >>b.x >>b.y>>b.z ;
    cout<<"直线点斜式为:(x-"<<a.x <<")/("<<b.x <<"-"<<a.x <<")=(y-"<<a.y <<")/("<<b.y <<"-"<<a.y <<")=z-"<<a.z <<")/("<<b.z <<"-"<<a.z <<")"<<endl;
    cout<<endl;
    }
    void A2()
    {
    Point a,b,c;
    cout<<"输入三个点的坐标:"<<endl;
    cin>>a.x >>a.y >>a.z >>b.x >>b.y>>b.z >>c.x >>c.y>>c.z ;
    double A,B,C;
    A=(c.y -a.y)*(c.z -a.z )-(b.z -a.z )*(c.y -a.y );
    B=(c.x -a.x )*(b.z -a.z )-(b.x-a.x )*(c.z -a.z );
    C=(b.x -a.x )*(c.y -a.y )-(c.x -a.x )*(b.y -a.y );
    double D;
    D=-1*(A*a.x +B*a.y +C*a.z);
    cout<<"方程为:"<<A<<"x+"<<B<<"y+"<<C<<"z+"<<D<<"=0"<<endl;
    }
    void B2()
    {
    double x,y,z,a,b,c;
    cout<<"输入点与法向量:"<endl;
    cin>>x,y,z,a,b,c;
    cout<<"该平面为:(x-"<<x<<")"<<a<<"+(y-"<<y<<")"<<b<<"+(z-"<<z<<")"<<c<<"=0"<<endl;
    }
    void A3()
    {
    Point a,b;
    cout<<"输入两点坐标:"<<endl;
    cin>>a.x >>a.y >>a.z >>b.x >>b.y>>b.z ;
    cout<<"距离为:"<<sqrt((a.x-b.x )*(a.x -b.x )+(a.y -b.y )*(a.y -b.y )+(a.z -b.z )*(a.z -b.z ))<<end;
    }
    void A3()
    {
    Point a;
    cout<<"输入点与直线方程参数:"<<endl;
    double x,y,z,d;
    cout<<"距离为:"<<(a.x *x+a.y *y+a.z *z)/(sqrt(x*x+y*y+z*z))<<endl;
    };
    void A4()
    {
    Point a;
    double x,y,z,d;
    cout<<"输入点a与平面方程ax+by+cz+d=0的参数:"<<endl;
    cout<<"距离为:"<<(a.x *x+a.y *y+a.z *z)/(sqrt(x*x+y*y+z*z))<<endl;
    }
    void A5()
    {
    double x,y,z;
    cout<<"输入空间直线ax+by+cz+d=0参数:"<<endl;
    cin>>x>>y>>z;
    double d;
    d=sqrt(x*x+y*y+z*z);
    cout<<"单位向量:("<<x/d<<","<<y/d<<","<<z/d<<")"<<endl;
    }
    void A5()
    {
    double x,y,z;
    cout<<"输入空间平面ax+by+cz+d=0参数:"<<endl;
    cin>>x>>y>>z;
    double d;
    d=sqrt(x*x+y*y+z*z);
    cout<<"单位向量:("<<x/d<<","<<y/d<<","<<z/d<<")"<<endl;
    }
    void A6()
    {
    Point a;
    double x,y,z;
    cout<<"输入点a空间直线ax+by+cz+d=0参数:"<<endl;
    cin>>a.x >>a.y >>a.z >>x>>y>>z;
    }
    int main()
    {
    int temp;
    cout<<"请选择:"<<endl;
    cout<<"1.两点确立一条直线"<<endl<<"2.两个相交平面确立一条直线"<<endl<<"3.空间曲线的点斜式"<<endl;
    cout<<"4.三个不同的点确定一个平面"<<endl<<"5.一个点一个法向量确定一个平面"<<endl;
    cout<<"6.两点之间的距离"<<endl<<"7.点到直线的距离"<<endl<<

  • 相关阅读:
    报数游戏
    Dynamics CRM 2013 初体验(2):UI
    Lucene.net常见功能实现知识汇总
    hdu 1853 最小费用流好题 环的问题
    MessagerService总结
    [置顶] Android EditText/TextView使用SpannableString显示复合文本
    MySQL Dll语句
    JavaScript表单验证
    intellij—idea14 注冊机
    OL记载Arcgis Server切片
  • 原文地址:https://www.cnblogs.com/ldy2396/p/14159275.html
Copyright © 2020-2023  润新知