Hello,

I am using clould reco example and added following method to CRParentViewControllerClass.

bool linePlaneIntersection(QCAR::Vec3F lineStart, QCAR::Vec3F lineEnd, QCAR::Vec3F pointOnPlane, QCAR::Vec3F planeNormal, QCAR::Vec3F &intersection) { QCAR::Vec3F lineDir = SampleMath::Vec3FSub(lineEnd, lineStart); lineDir = SampleMath::Vec3FNormalize(lineDir); QCAR::Vec3F planeDir = SampleMath::Vec3FSub(pointOnPlane, lineStart); float n = SampleMath::Vec3FDot(planeNormal, planeDir); float d = SampleMath::Vec3FDot(planeNormal, lineDir); if (fabs(d) < 0.00001) { // Line is parallel to plane return false; } float dist = n / d; QCAR::Vec3F offset = SampleMath::Vec3FScale(lineDir, dist); intersection = SampleMath::Vec3FAdd(lineStart, offset); return true; } void projectScreenPointToPlane(QCAR::Vec2F point, QCAR::Vec3F planeCenter, QCAR::Vec3F planeNormal, QCAR::Vec3F &intersection, QCAR::Vec3F &lineStart, QCAR::Vec3F &lineEnd) { CloudRecoAppDelegate* delegate = (CloudRecoAppDelegate*)[[UIApplication sharedApplication] delegate]; QCARutils *qUtils = [QCARutils getInstance]; // Window Coordinates to Normalized Device Coordinates QCAR::VideoBackgroundConfig config = QCAR::Renderer::getInstance().getVideoBackgroundConfig(); float halfScreenWidth = qUtils.viewSize.height / 2.0f; // note use of height for width float halfScreenHeight = qUtils.viewSize.width / 2.0f; // likewise float halfViewportWidth = config.mSize.data[0] / 2.0f; float halfViewportHeight = config.mSize.data[1] / 2.0f; float x = (qUtils.contentScalingFactor * point.data[0] - halfScreenWidth) / halfViewportWidth; float y = (qUtils.contentScalingFactor * point.data[1] - halfScreenHeight) / halfViewportHeight * -1; QCAR::Vec4F ndcNear(x, y, -1, 1); QCAR::Vec4F ndcFar(x, y, 1, 1); // Normalized Device Coordinates to Eye Coordinates QCAR::Matrix44F projectionMatrix = [QCARutils getInstance].projectionMatrix; QCAR::Matrix44F inverseProjMatrix = SampleMath::Matrix44FInverse(projectionMatrix); QCAR::Vec4F pointOnNearPlane = SampleMath::Vec4FTransform(ndcNear, inverseProjMatrix); QCAR::Vec4F pointOnFarPlane = SampleMath::Vec4FTransform(ndcFar, inverseProjMatrix); pointOnNearPlane = SampleMath::Vec4FDiv(pointOnNearPlane, pointOnNearPlane.data[3]); pointOnFarPlane = SampleMath::Vec4FDiv(pointOnFarPlane, pointOnFarPlane.data[3]); if ([delegate.modelViewMatrix count] > 0){ for ( int vv = 0 ; vv < 16 ; vv++){ //NSLog(@"use::vv%d::%@",vv,delegate.modelViewMatrix[vv]); modelUse.data[vv] = [[delegate.modelViewMatrix objectAtIndex:vv] floatValue]; } } // Eye Coordinates to Object Coordinates QCAR::Matrix44F inverseModelViewMatrix = SampleMath::Matrix44FInverse(modelUse); QCAR::Vec4F nearWorld = SampleMath::Vec4FTransform(pointOnNearPlane, inverseModelViewMatrix); QCAR::Vec4F farWorld = SampleMath::Vec4FTransform(pointOnFarPlane, inverseModelViewMatrix); lineStart = QCAR::Vec3F(nearWorld.data[0], nearWorld.data[1], nearWorld.data[2]); lineEnd = QCAR::Vec3F(farWorld.data[0], farWorld.data[1], farWorld.data[2]); linePlaneIntersection(lineStart, lineEnd, planeCenter, planeNormal, intersection); }

This method is called as

QCAR::Vec3F intersection, lineStart, lineEnd; projectScreenPointToPlane(QCAR::Vec2F(location.x, location.y), QCAR::Vec3F(0, 0, 0), QCAR::Vec3F(0, 0, 1), intersection, lineStart, lineEnd); NSLog(@"intersection Point: %f:%f:%f",intersection.data[0],intersection.data[1],intersection.data[2]);

However the touch point that I am getting is looking off. When I start touching the screen in potrait mode - touching the screen from top to down decreases the data[1] of the intersection point and touch from left to right increases the data[0] of the intersection point. I was expecting it to be reverse.

Can you please advice why this would be.

Hi Victor,

I just wondered whether you check this previous thread where you were part of the discussion?

https://developer.vuforia.com/forum/ios/3d-touch-error

There, another developer had similar issues to yours and seemed to get to the bottom of it. There it turned out to be due to the various rotations being handled incorrectly in the view hierarchy.

Can you please check?

cheers

N