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 static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE; 20 21 import android.annotation.NonNull; 22 import android.os.Parcel; 23 import android.os.Parcelable; 24 25 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; 26 27 /** 28 * A point in 3D space, in millimeters. 29 * 30 * @hide 31 */ 32 public final class Point3D implements Parcelable { 33 /** The x-component of the point. */ 34 public final double x; 35 36 /** The y-component of the point. */ 37 public final double y; 38 39 /** The z-component of the point. */ 40 public final double z; 41 Point3D(double valueX, double valueY, double valueZ)42 public Point3D(double valueX, double valueY, double valueZ) { 43 x = valueX; 44 y = valueY; 45 z = valueZ; 46 } 47 48 @Override 49 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) describeContents()50 public int describeContents() { 51 return 0; 52 } 53 54 @Override writeToParcel(@onNull Parcel dest, int flags)55 public void writeToParcel(@NonNull Parcel dest, int flags) { 56 dest.writeDouble(x); 57 dest.writeDouble(y); 58 dest.writeDouble(z); 59 } 60 61 @Override toString()62 public String toString() { 63 return String.format("%f, %f, %f", x, y, z); 64 } 65 66 public static final @NonNull Parcelable.Creator<Point3D> CREATOR = 67 new Parcelable.Creator<Point3D>() { 68 public Point3D createFromParcel(Parcel in) { 69 return new Point3D(in); 70 } 71 72 public Point3D[] newArray(int size) { 73 return new Point3D[size]; 74 } 75 }; 76 Point3D(Parcel in)77 private Point3D(Parcel in) { 78 x = in.readDouble(); 79 y = in.readDouble(); 80 z = in.readDouble(); 81 } 82 } 83