Tanoda
LocalSegment2.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 public struct LocalSegment2 {
17
18 public Vector2 a, b;
19
20 public LocalSegment2(Vector2 a, Vector2 b) {
21 this.a = a;
22 this.b = b;
23 }
24
29 public float Parameterize(Vector2 pointOnSegment) {
30 if ((a - b).sqrMagnitude < float.Epsilon) return 0f;
31 return (pointOnSegment - a).magnitude / (b - a).magnitude;
32 }
33
34 //public LocalSegment3 WithZ(float z) {
35 // return new LocalSegment3(a.WithZ(z), b.WithZ(z));
36 //}
37
38 }
39
40}
float Parameterize(Vector2 pointOnSegment)
Given a point on the segment, parameterizes that point into a value such that a + (b - a)....
LocalSegment2(Vector2 a, Vector2 b)