private static float calculateDeltaRotation( Vector3 currentPosition1, Vector3 currentPosition2, Vector3 previousPosition1, Vector3 previousPosition2) { Vector3 currentDirection = Vector3.subtract(currentPosition1, currentPosition2).normalized(); Vector3 previousDirection = Vector3.subtract(previousPosition1, previousPosition2).normalized(); float sign = Math.signum( previousDirection.x * currentDirection.y - previousDirection.y * currentDirection.x); return Vector3.angleBetweenVectors(currentDirection, previousDirection) * sign; } }
Vector3 normal = Vector3.subtract(centerPoint, nextPoint).normalized(); Vertex center = Vertex.builder()
lerp(rotations.get(segmentIndex), rotations.get(segmentIndex + 1), .5f); Vector3 rightDirection = Quaternion.rotateVector(averagedRotation, Vector3.right()).normalized(); Vector3 upDirection = Quaternion.rotateVector(averagedRotation, Vector3.up()).normalized(); Vector3.add( rightDirection.scaled(radius * cosTheta), upDirection.scaled(radius * sinTheta)); Vector3 normal = position.normalized(); position.set(Vector3.add(position, influencePoint));
Vector3 firstToSecondDirection = firstToSecond.normalized(); previousPosition2.set(newPosition2); float dot1 = Vector3.dot(deltaPosition1.normalized(), firstToSecondDirection.negated()); float dot2 = Vector3.dot(deltaPosition2.normalized(), firstToSecondDirection); float dotThreshold = (float) Math.cos(Math.toRadians(SLOP_MOTION_DIRECTION_DEGREES));
Vector3 directionFromTopToBottom = difference.normalized(); Quaternion rotationFromAToB = Quaternion.lookRotation(directionFromTopToBottom, desiredUp); Quaternion.rotateVector(rotationFromAToB, Vector3.forward()).normalized(); Vector3 rightDirection = Quaternion.rotateVector(rotationFromAToB, Vector3.right()).normalized(); Vector3 upDirection = Quaternion.rotateVector(rotationFromAToB, Vector3.up()).normalized(); desiredUp.set(upDirection); rightDirection.scaled(radius * cosTheta), upDirection.scaled(radius * sinTheta))); Vector3 normal = Vector3.subtract(topPosition, directionFromTopToBottom.scaled(-halfHeight)).normalized(); topPosition = Vector3.add(topPosition, center); UvCoordinate uvCoordinate = new UvCoordinate(uStep * edgeIndex, 0); normal = Vector3.subtract(bottomPosition, directionFromTopToBottom.scaled(halfHeight)) .normalized(); bottomPosition = Vector3.add(bottomPosition, center); float vHeight = halfHeight * 2;