예제 #1
0
 private float doRotation(Vector3 center, Vector2 oldScreenPos, Vector2 newScreenPos,
                          ProjectionParams projectionParams)
 {
     var newVector = projectionParams.ProjectTo(newScreenPos, TransformPlane) - center;
     var oldVector = projectionParams.ProjectTo(oldScreenPos, TransformPlane) - center;
     var angle = Vector3.Angle(oldVector, newVector);
     if (Vector3.Dot(Vector3.Cross(oldVector, newVector), TransformPlane.normal) < 0)
         angle = -angle;
     return angle;
 }
예제 #2
0
 private float doScaling(Vector3 center, Vector2 oldScreenPos, Vector2 newScreenPos,
                         ProjectionParams projectionParams)
 {
     var newVector = projectionParams.ProjectTo(newScreenPos, TransformPlane) - center;
     var oldVector = projectionParams.ProjectTo(oldScreenPos, TransformPlane) - center;
     return newVector.magnitude / oldVector.magnitude;
 }
예제 #3
0
 /// <inheritdoc />
 private Vector3 projectScaledRotated(Vector2 point, float dR, float dS, ProjectionParams projectionParams)
 {
     var delta = projectionParams.ProjectTo(point, TransformPlane) - cachedTransform.position;
     if (dR != 0) delta = Quaternion.AngleAxis(dR, RotationAxis) * delta;
     if (dS != 0) delta = delta * dS;
     return cachedTransform.position + delta;
 }
예제 #4
0
        /// <inheritdoc />
        protected override Vector3 doTwoPointTranslation(Vector2 oldScreenPos1, Vector2 oldScreenPos2,
                                                         Vector2 newScreenPos1, Vector2 newScreenPos2, float dR, float dS, ProjectionParams projectionParams)
        {
            if (isTransforming)
            {
                return projectionParams.ProjectTo(newScreenPos1, TransformPlane) - projectScaledRotated(oldScreenPos1, dR, dS, projectionParams);
            }

            screenPixelTranslationBuffer += newScreenPos1 - oldScreenPos1;
            if (screenPixelTranslationBuffer.sqrMagnitude > screenTransformPixelThresholdSquared)
            {
                isTransforming = true;
                return projectionParams.ProjectTo(newScreenPos1, TransformPlane) -
                       projectScaledRotated(newScreenPos1 - screenPixelTranslationBuffer, dR, dS, projectionParams);
            }

            return Vector3.zero;
        }
예제 #5
0
        /// <inheritdoc />
        protected override Vector3 doOnePointTranslation(Vector2 oldScreenPos, Vector2 newScreenPos,
                                                         ProjectionParams projectionParams)
        {
            if (isTransforming)
            {
                return projectionParams.ProjectTo(newScreenPos, TransformPlane) -
                       projectionParams.ProjectTo(oldScreenPos, TransformPlane);
            }

            screenPixelTranslationBuffer += newScreenPos - oldScreenPos;
            if (screenPixelTranslationBuffer.sqrMagnitude > screenTransformPixelThresholdSquared)
            {
                isTransforming = true;
                return projectionParams.ProjectTo(newScreenPos, TransformPlane) -
                       projectionParams.ProjectTo(newScreenPos - screenPixelTranslationBuffer, TransformPlane);
            }

            return Vector3.zero;
        }
예제 #6
0
 /// <inheritdoc />
 protected override float doScaling(Vector2 oldScreenPos1, Vector2 oldScreenPos2, Vector2 newScreenPos1,
                                    Vector2 newScreenPos2, ProjectionParams projectionParams)
 {
     var newVector = projectionParams.ProjectTo(newScreenPos2, TransformPlane) -
                     projectionParams.ProjectTo(newScreenPos1, TransformPlane);
     var oldVector = projectionParams.ProjectTo(oldScreenPos2, TransformPlane) -
                     projectionParams.ProjectTo(oldScreenPos1, TransformPlane);
     return newVector.magnitude / oldVector.magnitude;
 }
예제 #7
0
 /// <inheritdoc />
 protected override float doRotation(Vector2 oldScreenPos1, Vector2 oldScreenPos2, Vector2 newScreenPos1,
                                     Vector2 newScreenPos2, ProjectionParams projectionParams)
 {
     var newVector = projectionParams.ProjectTo(newScreenPos2, TransformPlane) -
                     projectionParams.ProjectTo(newScreenPos1, TransformPlane);
     var oldVector = projectionParams.ProjectTo(oldScreenPos2, TransformPlane) -
                     projectionParams.ProjectTo(oldScreenPos1, TransformPlane);
     var angle = Vector3.Angle(oldVector, newVector);
     if (Vector3.Dot(Vector3.Cross(oldVector, newVector), TransformPlane.normal) < 0)
         angle = -angle;
     return angle;
 }