Skip to content

acl/compression/transform_metrics.h

#include "acl/compression/transform_metrics.h"

The interface of a transform metric, and the built-in metrics that measure the error between a raw and a lossy transform.

itransform_metric

class itransform_metric

Interface for all transform metrics. A transform metric measures the error between a raw and a lossy transform. It uses the transforms only through a transform adapter. Thus one metric can measure the error of each runtime transform type that it supports.

We measure the error on a rigid shell around each transform: a sphere at a certain distance from the transform. See ./docs/error_metrics.md for details.

itransform_metric::get_name

virtual const char* get_name() const =0

Returns the unique name of the transform metric.

itransform_metric::get_hash

virtual uint32_t get_hash() const

Returns a unique hash to represent the transform metric.

itransform_metric::is_supported

virtual bool is_supported(const itransform_adapter& adapter) const =0

Returns whether or not the metric can measure the error of transforms that use the provided transform adapter.

itransform_metric::calculate_error

rtm::scalarf calculate_error(const calculate_error_args& args) const

Measures the error between a raw and lossy transform.

itransform_metric::calculate_error_squared

virtual rtm::scalarf calculate_error_squared(const calculate_error_args& args) const =0

Measures the squared error between a raw and lossy transform.

itransform_metric::calculate_error_args

struct itransform_metric::calculate_error_args

Input arguments for the calculate_error* functions.

itransform_metric::calculate_error_args::shell_points_xxxx

rtm::vector4f shell_points_xxxx;

The points on the rigid shell, stored transposed. The X, Y, and Z lanes hold the points along the X, Y, and Z axes. The W lane holds a point between the three axes.

itransform_metric::calculate_error_args::shell_points_yyyy

rtm::vector4f shell_points_yyyy;

The points on the rigid shell, stored transposed. The X, Y, and Z lanes hold the points along the X, Y, and Z axes. The W lane holds a point between the three axes.

itransform_metric::calculate_error_args::shell_points_zzzz

rtm::vector4f shell_points_zzzz;

The points on the rigid shell, stored transposed. The X, Y, and Z lanes hold the points along the X, Y, and Z axes. The W lane holds a point between the three axes.

itransform_metric::calculate_error_args::shell_distance

float shell_distance;

The distance from the transform to the rigid shell: the radius of the sphere.

itransform_metric::calculate_error_args::adapter

const itransform_adapter* adapter;

The transform adapter of the two transforms.

itransform_metric::calculate_error_args::transform0

const void* transform0;

The raw transform, in the runtime type of the adapter. Could be in local or object space (same space as the lossy transform).

itransform_metric::calculate_error_args::transform1

const void* transform1;

The lossy transform, in the runtime type of the adapter. Could be in local or object space (same space as the raw transform).

itransform_metric::calculate_error_args::construct_sphere_shell

void construct_sphere_shell(float shell_distance_)

Sets the shell points for a sphere with the provided radius.

shell_transform_metric

class shell_transform_metric : public acl::itransform_metric

Measures the error on points of the rigid shell. It transforms the points with the raw and lossy transforms and returns the largest distance. It supports every transform adapter. With a scale, it measures three points; without a scale (VQ), two points. The points give an approximation of the error. Use it with transforms that have a 3D scale or a shear (VQV, VQM, or a matrix). For VQ and VQS transforms, precise_transform_metric gives the exact error.

shell_transform_metric::get_name

virtual const char* get_name() const override

Returns the unique name of the transform metric.

shell_transform_metric::is_supported

virtual bool is_supported(const itransform_adapter& adapter) const override

Returns whether or not the metric can measure the error of transforms that use the provided transform adapter.

shell_transform_metric::calculate_error_squared

virtual rtm::scalarf calculate_error_squared(
    const calculate_error_args& args) const override

Measures the squared error between a raw and lossy transform.

precise_transform_metric

class precise_transform_metric : public acl::itransform_metric

Measures the exact largest error on the rigid shell, for VQ and VQS transforms. It uses the rotation, the translation, and the uniform scale to find the point on the sphere with the largest error. It computes with float64. With a VQS transform, when the raw and lossy scales are not equal, the result can be above the exact error by no more than |s1 - s0| * shell_distance. See calculate_vqs_error_squared_precise. It supports only the vqf and vqsf transform adapters.

precise_transform_metric::get_name

virtual const char* get_name() const override

Returns the unique name of the transform metric.

precise_transform_metric::is_supported

virtual bool is_supported(const itransform_adapter& adapter) const override

Returns whether or not the metric can measure the error of transforms that use the provided transform adapter.

precise_transform_metric::calculate_error_squared

virtual rtm::scalarf calculate_error_squared(
    const calculate_error_args& args) const override

Measures the squared error between a raw and lossy transform.