Tanoda
CopyFromOtherExtensions.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
9namespace Leap {
10
11 public static class CopyFromOtherExtensions {
12
19 public static Frame CopyFrom(this Frame frame, Frame source) {
20 frame.Id = source.Id;
21 frame.Timestamp = source.Timestamp;
22 frame.CurrentFramesPerSecond = source.CurrentFramesPerSecond;
23
24 frame.ResizeHandList(source.Hands.Count);
25
26 for (int i = frame.Hands.Count; i-- != 0;) {
27 frame.Hands[i].CopyFrom(source.Hands[i]);
28 }
29
30 return frame;
31 }
32
33 /*
34 * Copies the data from a source hand into a hand. After the operation is
35 * complete, the hand will be identical to the source hand.
36 *
37 * @param source The source hand that is copied into a hand.
38 */
39 public static Hand CopyFrom(this Hand hand, Hand source) {
40 hand.Id = source.Id;
41 hand.Confidence = source.Confidence;
42 hand.GrabStrength = source.GrabStrength;
43 hand.GrabAngle = source.GrabAngle;
44 hand.Rotation = source.Rotation;
45 hand.PinchStrength = source.PinchStrength;
46 hand.PinchDistance = source.PinchDistance;
47 hand.PalmWidth = source.PalmWidth;
48 hand.IsLeft = source.IsLeft;
49 hand.TimeVisible = source.TimeVisible;
50 hand.PalmPosition = source.PalmPosition;
51 hand.StabilizedPalmPosition = source.StabilizedPalmPosition;
52 hand.PalmVelocity = source.PalmVelocity;
53 hand.PalmNormal = source.PalmNormal;
54 hand.Direction = source.Direction;
55 hand.WristPosition = source.WristPosition;
56
57 hand.Arm.CopyFrom(source.Arm);
58
59 for (int i = 5; i-- != 0;) {
60 hand.Fingers[i].CopyFrom(source.Fingers[i]);
61 }
62
63 return hand;
64 }
65
72 public static Finger CopyFrom(this Finger finger, Finger source) {
73 for (int i = 4; i-- != 0;) {
74 finger.bones[i].CopyFrom(source.bones[i]);
75 }
76
77 finger.Id = source.Id;
78 finger.HandId = source.HandId;
79 finger.TimeVisible = source.TimeVisible;
80
81 finger.TipPosition = source.TipPosition;
82 finger.Direction = source.Direction;
83 finger.Width = source.Width;
84 finger.Length = source.Length;
85 finger.IsExtended = source.IsExtended;
86 finger.Type = source.Type;
87
88 return finger;
89 }
90
97 public static Bone CopyFrom(this Bone bone, Bone source) {
98 bone.PrevJoint = source.PrevJoint;
99 bone.NextJoint = source.NextJoint;
100 bone.Direction = source.Direction;
101 bone.Center = source.Center;
102 bone.Length = source.Length;
103 bone.Width = source.Width;
104 bone.Rotation = source.Rotation;
105 bone.Type = source.Type;
106
107 return bone;
108 }
109 }
110}