RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
Translation3dStruct.java
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5package org.wpilib.math.geometry.struct;
6
7import java.nio.ByteBuffer;
8import org.wpilib.math.geometry.Translation3d;
9import org.wpilib.util.struct.Struct;
10
11public final class Translation3dStruct implements Struct<Translation3d> {
12 @Override
13 public Class<Translation3d> getTypeClass() {
14 return Translation3d.class;
15 }
16
17 @Override
18 public String getTypeName() {
19 return "Translation3d";
20 }
21
22 @Override
23 public int getSize() {
24 return DOUBLE_SIZE * 3;
25 }
26
27 @Override
28 public String getSchema() {
29 return "double x;double y;double z";
30 }
31
32 @Override
33 public Translation3d unpack(ByteBuffer bb) {
34 double x = bb.getDouble();
35 double y = bb.getDouble();
36 double z = bb.getDouble();
37 return new Translation3d(x, y, z);
38 }
39
40 @Override
41 public void pack(ByteBuffer bb, Translation3d value) {
42 bb.putDouble(value.getX());
43 bb.putDouble(value.getY());
44 bb.putDouble(value.getZ());
45 }
46
47 @Override
48 public boolean isImmutable() {
49 return true;
50 }
51}