Tanoda
LocalPlane.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using Leap.Unity.Infix;
10using System.Collections;
11using System.Collections.Generic;
12using UnityEngine;
13
14namespace Leap.Unity.Geometry {
15
16 [System.Serializable]
20 public struct LocalPlane {
21
22 public Vector3 position;
23 public Vector3 normal;
24
25 public LocalPlane(Vector3 position, Vector3 normal) {
26 this.position = position;
27 this.normal = normal;
28 }
29
30 public Plane With(Transform t) {
31 return new Plane(position, normal, t);
32 }
33
34 }
35
36 public static class LocalPlaneExtensions {
37
42 public static LocalPlane ToWorldPlane(this Rect rect) {
43 var pose = rect.pose;
44 return new LocalPlane(pose.position, pose.rotation * Rect.PLANE_NORMAL);
45 }
46
51 public static LocalPlane ToLocalPlane(this Rect rect) {
52 var pose = rect.pose;
53 return new LocalPlane(Vector3.zero, Rect.PLANE_NORMAL);
54 }
55
56 }
57
58}
A transformless Plane defined by a position and normal vector.
Definition: LocalPlane.cs:20
Plane With(Transform t)
Definition: LocalPlane.cs:30
LocalPlane(Vector3 position, Vector3 normal)
Definition: LocalPlane.cs:25