码迷,mamicode.com
首页 > 其他好文 > 详细

2020.7.7 每日记录

时间:2020-07-07 23:32:56      阅读:64      评论:0      收藏:0      [点我收藏+]

标签:成绩   函数   小学   直线   今天   set   代码   函数实现   每日   

高考到了,祝愿考生能取得自己满意的成绩。

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

#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<<

2020.7.7 每日记录

标签:成绩   函数   小学   直线   今天   set   代码   函数实现   每日   

原文地址:https://www.cnblogs.com/fuxw4971/p/13264175.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!