1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.car.occupantawareness; 18 19 import android.annotation.NonNull; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 23 /** 24 * A point in 3D space, in millimeters. 25 * 26 * @hide 27 */ 28 public final class Point3D implements Parcelable { 29 /** The x-component of the point. */ 30 public final double x; 31 32 /** The y-component of the point. */ 33 public final double y; 34 35 /** The z-component of the point. */ 36 public final double z; 37 Point3D(double valueX, double valueY, double valueZ)38 public Point3D(double valueX, double valueY, double valueZ) { 39 x = valueX; 40 y = valueY; 41 z = valueZ; 42 } 43 44 @Override describeContents()45 public int describeContents() { 46 return 0; 47 } 48 49 @Override writeToParcel(@onNull Parcel dest, int flags)50 public void writeToParcel(@NonNull Parcel dest, int flags) { 51 dest.writeDouble(x); 52 dest.writeDouble(y); 53 dest.writeDouble(z); 54 } 55 56 @Override toString()57 public String toString() { 58 return String.format("%f, %f, %f", x, y, z); 59 } 60 61 public static final @NonNull Parcelable.Creator<Point3D> CREATOR = 62 new Parcelable.Creator<Point3D>() { 63 public Point3D createFromParcel(Parcel in) { 64 return new Point3D(in); 65 } 66 67 public Point3D[] newArray(int size) { 68 return new Point3D[size]; 69 } 70 }; 71 Point3D(Parcel in)72 private Point3D(Parcel in) { 73 x = in.readDouble(); 74 y = in.readDouble(); 75 z = in.readDouble(); 76 } 77 } 78