public class

DVector2

extends java.lang.Object

 java.lang.Object

↳androidx.input.motionprediction.kalman.matrix.DVector2

Gradle dependencies

compile group: 'androidx.input', name: 'input-motionprediction', version: '1.0.0-beta04'

  • groupId: androidx.input
  • artifactId: input-motionprediction
  • version: 1.0.0-beta04

Artifact androidx.input:input-motionprediction:1.0.0-beta04 it located at Google repository (https://maven.google.com/)

Overview

A 2 element fixed sized vector, where each element is a double. This class can represent a (2x1) or (1x2) matrix.

Summary

Fields
public doublea1

public doublea2

Constructors
publicDVector2()

Methods
public doublemagnitude()

Returns the vector magnitude (abs, length).

public voidset(DVector2 newValue)

Sets the elements to the values from newValue.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public double a1

public double a2

Constructors

public DVector2()

Methods

public double magnitude()

Returns the vector magnitude (abs, length).

public void set(DVector2 newValue)

Sets the elements to the values from newValue.

Source

/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.input.motionprediction.kalman.matrix;

import static androidx.annotation.RestrictTo.Scope.LIBRARY;

import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;

/**
 * A 2 element fixed sized vector, where each element is a double. This class can represent a (2x1)
 * or (1x2) matrix.
 *
 */
@RestrictTo(LIBRARY)
public class DVector2 {
    public double a1;
    public double a2;

    public DVector2() {}

    /** Returns the vector magnitude (abs, length). */
    public double magnitude() {
        return Math.hypot(a1, a2);
    }

    /** Sets the elements to the values from {@code newValue}. */
    public void set(@NonNull DVector2 newValue) {
        a1 = newValue.a1;
        a2 = newValue.a2;
    }
}