教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 专业资料 >

坐标转换c++代码

来源:网络收集 时间:2026-10-03
导读: #includeiostream #includefstream #includeiomanip using namespace std; void sd(double *s,int n,ofstream outfile); void main() { int x; double s[4]; //存储读入数据 ifstream fin(90.pts); //打开原始数据 ofstream outfile(ldb.pts);//写出原始数据

#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
void sd(double *s,int n,ofstream &outfile);
void main()
{
int x;
double s[4]; //存储读入数据
ifstream fin("90.pts"); //打开原始数据
ofstream outfile("ldb.pts");//写出原始数据
fin>>x;
outfile<<x<<endl;
for(int i=0;i<x;i++) //读入原始数据
{
for(int j=0;j<4;j++)
{
fin>>s[j];
}
sd(s,4,outfile); //调用转换参数,进行坐标转化,并写入转换后文件
}
fin.close(); //关闭原始数据
outfile.close(); //关闭写入数据
}

void sd(double *s,int n,ofstream &outfile) //坐标转换函数
{

double d[3][3]={{-0.0968,0.9933,0.063},{-0.9950,-0.0982,0.0201},{0.0263,-0.0614,0.9978}};//坐标系转化矩阵
double a[3]={-8.3491,2.0209,0.0068};//坐标系平移参数
double b[3];
b[0]=d[0][0]*(*s)+d[0][1]*(*(s+1))+d[0][2]*(*(s+2))+a[0];
b[1]=d[1][0]**(s)+d[1][1]**(s+1)+d[1][2]**(s+2)+a[1];
b[2]=d[2][0]**(s)+d[2][1]**(s+1)+d[2][2]**(s+2)+a[2];//计算转换后坐标
outfile.precision(6);
outfi
le<<b[0]<<" "<<b[1]<<" "<<b[2]<<" "<<*(s+3)<<endl;//输出转换后坐标

}

坐标转换c++代码.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/1758966.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150份
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150份
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)