getDistanceBetweenAnchors method

Future<double?> getDistanceBetweenAnchors(
  1. ARAnchor anchor1,
  2. ARAnchor anchor2
)

Returns the distance in meters between @anchor1 and @anchor2.

Implementation

Future<double?> getDistanceBetweenAnchors(
    ARAnchor anchor1, ARAnchor anchor2) async {
  var anchor1Pose = await getPose(anchor1);
  var anchor2Pose = await getPose(anchor2);
  var anchor1Translation = anchor1Pose?.getTranslation();
  var anchor2Translation = anchor2Pose?.getTranslation();
  if (anchor1Translation != null && anchor2Translation != null) {
    return getDistanceBetweenVectors(anchor1Translation, anchor2Translation);
  } else {
    return null;
  }
}