rotation - iPhone multi-touch move, scale and rotate, how to prevent scale? -


I have existing code to track multi-touch status and then rotate, rotate and scaling items - An image in this situation - appropriate.

The code really works well and is perfect in itself, although for this special work, I only need movement and rotation. What is happening in this period? Have spent time learning to know, but mathematics is not my strong point, so want to see if someone can help?

  - Along with incremental conversion (Cagefin transform): *) Touch {NSArray * sortedTouches = [[touches all objects] Sorted Selector: @Selector (compare address) ]; NSInteger numTouches = [Sorting counting]; // if no touch (numTouches == 0) {Return CGAffineTransformIdentity; } // Single touch if (numTouches == 1) {UITouch * touch = [sortedTouches objectAtIndex: 0]; CGPoint startpoint = * (CGPoint *) CFFGet value (touchbointpoints, touch); CGPoint movepoint = [Touch Location Invoice: self Superviv]; Return CGAffineTransformMakeTranslation (current Point.x - beginPoint.x, currentPoint.y - beginPoint.y); } // If touching two or more, then the first two (sorted by the address) UITT * touch1 = [sorted item octack andx: 0]; UITouch * Touch2 = [Sorted item objectIntex: 1]; CGPoint StartPoint 1 = * (CGPE * *) CFiGEJet Value (TouchBointPoint, Touch1); CGPoint movepoint 1 = [Touch 1 location invoice: self Superviv]; CGPoint startpoint 2 = * (CGPOON * *) CFiDiaget value (TouchBointPoints, Touch2); CGPoint movepoint 2 = [Touch 2 location inview: self. Superviv]; Double Layerx = Self. center. X; Double Layer Y = self.center.y; Double X1 = Start Point1.x - layerX; Double y1 = beginPoint1.y - layer y; Double X2 = Start Point2.x - layerX; Double y2 = beginPoint2.y - layer y; Double X3 = Current Point 1.x - Layer X; Double y3 = current point 1.y - layer y; Double X4 = Current Point 2.x - Layer X; Double y4 = current point2.y - layer y; // Resolve system: // [abt t1, -bba t2, 0] 1, [x1, y1, 1] = [x3, y3, 1] // [abt 1 t, -baby t2 , 0 0] * [X2, y2, 1] = [x4, y4, 1] double D = (y1-y2) * (y1-y2) + (x1-x2) * (x1-x2); If (D & lt; 0.1) {Return CGAffineTransformMakeTranslation (x3-x1, y3-y1); } Double A = (y1-y2) * (y3-y4) + (x1-x2) * (x3-x4); Double b = (y1-y2) * (x3-x4) - (x1-x2) * (y3-y4); Double tx = (y1 * x2 - x1 * y2) * (y4-y3) - (x1 * x2 + y1 * y2) * (x3 + x4) + x3 * (y2 * y2 + x2 * x2) + x4 * ( Y1 * y1 + x1 * x1); Double type = (x1 * x2 + y1 * y2) * (- y4-y3) + (y1 * x2 - x1 * y2) * (x3-x4) + y3 * (y2 * y2 + x2 * x2) + y4 * (Y1 * y1 + x1 * x1); Return CGAffineTransformMake (A / D, -B / D, B / D, A / D, Tx / D, T / D); }  

I have tried to read on the work of the matrix, but it is not fully understood, the issue is more likely to be that which I have mentioned That's not my strong point.

What I need from this routine is a change that makes my movement and rotation but ignores the scale - so the distance between the two finger touch points is ignored and the scale is not affected is.

I have looked at other routines on the Internet to handle multi-touch rotation, but I would appreciate any help or some other (lubricant

)

Do something like this:

CGFini Transforms transform = self. View.transform; float scale = sqrt (transform.a * transform.a + transform.c * transform.c); self.view.transform = CGAffineTransformScale (transform, 1 / scale, 1 / scale); < / Pre>

of your missing Lastly: Lately: Along with: And UpdateOperal Transformer Touch Method In practice, you calculate the value of the current scale, then multiply your conversion metrics with the value of the reverse scale.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -