Converting meters to millimeters

Hello,

I am trying to convert meters to millimeters in a app. I have this so far and need some help.


- (void)presentMeshViewer:(STMesh *)mesh

{

[_meshViewController setupGL:_display.context];

_meshViewController.colorEnabled = _useColorCamera;

_meshViewController.mesh = mesh;

[_meshViewController setCameraProjectionMatrix:_display.depthCameraGLProjectionMatrix];

/

int totalNumVertices = 0;

for( int i=0; i<mesh.numberOfMeshes; ++i )

totalNumVertices += [mesh numberOfMeshVertices:i];

NSLog (@"totalNumVertices: %d",totalNumVertices);

/

int sampleStep = std::max (1.f, totalNumVertices/1000.f);

NSLog (@"sampleStep: %d",sampleStep);

int sampleCount = 0;

GLKVector3 volumeCenter = GLKVector3Make(0,0,0);

for( int i=0; i<mesh.numberOfMeshes; ++i )

{

int numVertices = [mesh numberOfMeshVertices:i];

NSLog (@"numVertices: %d",numVertices);

const GLKVector3* vertex = [mesh meshVertices:i];

for( int j=0; j<numVertices; j+=sampleStep )

{

vertex[j].x = vertex[j].x * 1000.0;

vertex[j].y = vertex[j].y * 1000.0;

vertex[j].z = vertex[j].z * 1000.0;

volumeCenter = GLKVector3Add(volumeCenter, vertex[j]);

sampleCount++;

}

}

NSLog(@"volumeCenter :(%f,%f,%f)", volumeCenter.x,volumeCenter.y,volumeCenter.z);

if( sampleCount>0 )

volumeCenter = GLKVector3DivideScalar(volumeCenter, sampleCount);

else

volumeCenter = GLKVector3MultiplyScalar(_slamState.volumeSizeInMeters, 0.5);

[_meshViewController resetMeshCenter:volumeCenter];

if (scanRightfoot)

_meshViewController.currentScanningFoot = @"RIGHT";

else

_meshViewController.currentScanningFoot = @"LEFT";

_meshViewController._scannedPatient = scanningPatient;

[self presentViewController:_meshViewNavigationController animated:YES completion:^{}];

}

What specifically do you need help with? You may want to look at NSMeasurement and let iOS do the conversion for you.

I was told the code below was the correct code to use to convert a 3d scan in meters to millimeters. I must not have it in the correct place in the code in my first post.

vertex[j].x = vertex[j].x * 1000.0;

vertex[j].y = vertex[j].y * 1000.0;

vertex[j].z = vertex[j].z * 1000.0;

Converting meters to millimeters
 
 
Q