RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
Translation2dStruct.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.Translation2d;
9import org.wpilib.util.struct.Struct;
10
11public final class Translation2dStruct implements Struct<Translation2d> {
12 @Override
13 public Class<Translation2d> getTypeClass() {
14 return Translation2d.class;
15 }
16
17 @Override
18 public String getTypeName() {
19 return "Translation2d";
20 }
21
22 @Override
23 public int getSize() {
24 return DOUBLE_SIZE * 2;
25 }
26
27 @Override
28 public String getSchema() {
29 return "double x;double y";
30 }
31
32 @Override
33 public Translation2d unpack(ByteBuffer bb) {
34 double x = bb.getDouble();
35 double y = bb.getDouble();
36 return new Translation2d(x, y);
37 }
38
39 @Override
40 public void pack(ByteBuffer bb, Translation2d value) {
41 bb.putDouble(value.getX());
42 bb.putDouble(value.getY());
43 }
44
45 @Override
46 public boolean isImmutable() {
47 return true;
48 }
49}