I have compiled a scan with your coding and got strange results
the oriantion of the model is backwards to when I use my coding ?
and the rotation in my viewer is backwards to ?
I will check the values but think they are the same but different in + or -
I don't mind posting any of my work it's just how to do so, the example
is some 1MB in size for both files
the values are in reverse as in mine start in the Z - and end in the Z +
yours start in the Z + and end in the Z -
I have thought about this and I think my presentation and orientation
is correct.
If you look down from above the head ( in the plan view ) start the scan at the
back of the head and work round in a clockwise direction, this being the back of
the head is North the nose is South left ear is East and right ear is West.
Well, I'd love to go thru megabytes of data as anyone does. But on the other hand I stared a while at the code and found the problem (I think). It's the offset of the angle of Z:
I did check the differences and yours tripped up after the first profile ( count or step )
but only slight differences, the scan I used was of 127 profiles ( counts steps ) and
250 points 1/2 a head.
I think a true test would be to generate ax & az from ar and then reveres the calculation
to produce a new ar1 then compare ar with ar1 ?.
I will have a go with your new code and try and reduce my coding down a bit.
You are welcome to any of my scan data they do zip down.
Polar to Cartesian conversion where known values are raidus from datum 0.00 together with height values
these values are described as ar and ay with the conversion being ax & az
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
usingnamespace std;
constdouble PI = 3.14159265; //declare PI
float array[31750][2]; //declare array size and number of columns
float ar[31750]; //declare array ar
float ay[31750]; //etc
float ax[31750]; //etc
float az[31750]; //etc
int i; //declare i & j for run through
int j;
int main()
{
ofstream fout("c:\bust\bust_samples\sam_xyz_3.txt"); //output file value space value space valuen
ifstream in_file("C:\bust\bust_samples\sam_ry.txt"); //input file value space valuen
if(!in_file.is_open()) {
cout<<"File not opened"<<"n";
return 1;
}
for(i=0;i<31749;i++) {
for(j=0;j<2;j++) {
in_file >> array[i][j]; //read in to array
}
}
for(i=0; i<31749; i++){
for(j=0; j<1; j++){
ar[i] = array[i][j]; //split array for ar
}
}
for(i=0; i<31749; i++){
for(j=1; j<2; j++){
ay[i] = array[i][j]; //split array for ay
}
}
double angle = 1.40625; // set degree of rotation of profiles
int k = 250; // set number of points per profile
for(i=0; i<31749; i++){
ax[i] = sin(angle* PI / 180)* ar[i]; // use ar to calculate ax for each point
az[i] = cos(angle* PI / 180)* ar[i]; // use ar to calculate az for each point
if(i==k){ // when number of points are reached goto next profile
angle = angle + 1.40625; // add the increment of rotation
k = k + 250; // add the increment of points per profile
}
}
for(i=0; i<31748; i++){
fout<<ax[i]<<" "<<ay[i]<<" "<<az[i]<<"n"; // file out as (x) value space (y) value space (z) valuen
}
return 0;
}
Hm, it looks like that there's more elaboration needed for that. It's just that I don't have your background to veryfy those numbers (viewer) and sorry, but not much time on my side either.
I did check the differences and yours tripped up after the first profile ( count or step )
but only slight differences, the scan I used was of 127 profiles ( counts steps ) and
250 points 1/2 a head.
It is my work in reproducing the human head in 3D from laser line triangulation
scanning to computer control machining. For members of the general public
world wide.
The more I read this thread the more confused I get.
The title, Polar to Cartesian, suggests 2d data although your are talking about 3d data.
The polar coordinate system is a 2d system with coordinates (r,T). where r is a radial coordinate and T is an azimuthal (angular) coordinate. On a Cartesian frame, 0° is associated with the +x-axis and travels counterclockwise a T increases.
The 3d version of Polar coordinates, spherical coordinates, is defined by (r,T,P) where r is a radial coordinate, T is an azimuthal (angular) coordinate, and P is a zenith (angular) coordinate.
Another 3d system would be the cylindrical coordinate system, that is an extrusion of polar coordinates, (r,T,z). the polar coordinates would be in the xy-plane and the third coordinate is simply the z-value.
I can't, from the code, get it in my head what coordinate system you are reading in/inferring.
Edit: T = theta, P = Phi (site no longer displaying greek letters :0(