下面列出了怎么用java.lang.Float的API类实例代码及写法,或者点击链接到github查看源代码。
public void testFloatNarrowing() {
if (System.getProperty("os.arch").equals("armv7")) {
return;
}
float fmin = Float.NEGATIVE_INFINITY;
float fmax = Float.POSITIVE_INFINITY;
assertEquals("fmin as long failed", Long.MIN_VALUE, (long) fmin);
assertEquals("fmax as long failed", Long.MAX_VALUE, (long) fmax);
assertEquals("fmin as int failed", Integer.MIN_VALUE, (int) fmin);
assertEquals("fmax as int failed", Integer.MAX_VALUE, (int) fmax);
assertEquals("fmin as char failed", Character.MIN_VALUE, (char) fmin);
assertEquals("fmax as char failed", Character.MAX_VALUE, (char) fmax);
// Surprising values for shorts and bytes, but that's what's specified.
assertEquals("fmin as short failed", 0, (short) fmin);
assertEquals("fmax as short failed", -1, (short) fmax);
assertEquals("fmin as byte failed", 0, (byte) fmin);
assertEquals("fmax as byte failed", -1, (byte) fmax);
}
private SetHomePosition(int targetSystem, int latitude, int longitude, int altitude, float x,
float y, float z, List<Float> q, float approachX, float approachY, float approachZ,
BigInteger timeUsec) {
this.targetSystem = targetSystem;
this.latitude = latitude;
this.longitude = longitude;
this.altitude = altitude;
this.x = x;
this.y = y;
this.z = z;
this.q = q;
this.approachX = approachX;
this.approachY = approachY;
this.approachZ = approachZ;
this.timeUsec = timeUsec;
}
private TrajectoryRepresentationWaypoints(BigInteger timeUsec, int validPoints,
List<Float> posX, List<Float> posY, List<Float> posZ, List<Float> velX,
List<Float> velY, List<Float> velZ, List<Float> accX, List<Float> accY,
List<Float> accZ, List<Float> posYaw, List<Float> velYaw, EnumValue<MavCmd> command) {
this.timeUsec = timeUsec;
this.validPoints = validPoints;
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.velX = velX;
this.velY = velY;
this.velZ = velZ;
this.accX = accX;
this.accY = accY;
this.accZ = accZ;
this.posYaw = posYaw;
this.velYaw = velYaw;
this.command = command;
}
private Odometry(BigInteger timeUsec, EnumValue<MavFrame> frameId,
EnumValue<MavFrame> childFrameId, float x, float y, float z, List<Float> q, float vx,
float vy, float vz, float rollspeed, float pitchspeed, float yawspeed,
List<Float> poseCovariance, List<Float> velocityCovariance, int resetCounter,
EnumValue<MavEstimatorType> estimatorType) {
this.timeUsec = timeUsec;
this.frameId = frameId;
this.childFrameId = childFrameId;
this.x = x;
this.y = y;
this.z = z;
this.q = q;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.rollspeed = rollspeed;
this.pitchspeed = pitchspeed;
this.yawspeed = yawspeed;
this.poseCovariance = poseCovariance;
this.velocityCovariance = velocityCovariance;
this.resetCounter = resetCounter;
this.estimatorType = estimatorType;
}
public RGBAColor(Float r, Float g, Float b, Float a, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
/**
* Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation
* direction motors is 0..1, negative range for reverse direction. Standard mapping for
* attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers,
* airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs.
*/
@MavlinkFieldInfo(
position = 3,
unitSize = 4,
arraySize = 8,
description = "Actuator controls. Normed to -1..+1 where 0 is neutral position. Throttle for single rotation direction motors is 0..1, negative range for reverse direction. Standard mapping for attitude controls (group 0): (index 0-7): roll, pitch, yaw, throttle, flaps, spoilers, airbrakes, landing gear. Load a pass-through mixer to repurpose them as generic outputs."
)
public final List<Float> controls() {
return this.controls;
}
@Override
public int hashCode() {
int result = 0;
result = result * 31 + Integer.valueOf(this.param1).hashCode();
result = result * 31 + Boolean.valueOf(this.param2).hashCode();
result = result * 31 + Float.valueOf(this.param3).hashCode();
return result * 31 + Double.valueOf(this.param4).hashCode();
}
public Layout(Float x, Float y, Float width, Float height, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
/**
* Change in position from previous to current frame rotated into body frame (0=forward,
* 1=right, 2=down).
*/
@MavlinkFieldInfo(
position = 4,
unitSize = 4,
arraySize = 3,
description = "Change in position from previous to current frame rotated into body frame (0=forward, 1=right, 2=down)."
)
public final List<Float> positionDelta() {
return this.positionDelta;
}
public EllipseArgs(Float x, Float y, Float radiusX, Float radiusY, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.x = x;
this.y = y;
this.radiusX = radiusX;
this.radiusY = radiusY;
}
public RGBAColor(Float r, Float g, Float b, Float a, ByteString unknownFields) {
super(ADAPTER, unknownFields);
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
/**
* {@inheritDoc}
*/
@Override
@NonNull
public BoxedTypesPrivateFieldsIgnoreNull mapFromCursor(@NonNull StorIOContentResolver storIOContentResolver, @NonNull Cursor cursor) {
Boolean field1 = null;
if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
}
Short field2 = null;
if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
field2 = cursor.getShort(cursor.getColumnIndex("field2"));
}
Integer field3 = null;
if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
field3 = cursor.getInt(cursor.getColumnIndex("field3"));
}
Long field4 = null;
if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
field4 = cursor.getLong(cursor.getColumnIndex("field4"));
}
Float field5 = null;
if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
}
Double field6 = null;
if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
}
BoxedTypesPrivateFieldsIgnoreNull object = new BoxedTypesPrivateFieldsIgnoreNull(field1, field2, field3, field4, field5, field6);
return object;
}
private HomePosition(int latitude, int longitude, int altitude, float x, float y, float z,
List<Float> q, float approachX, float approachY, float approachZ, BigInteger timeUsec) {
this.latitude = latitude;
this.longitude = longitude;
this.altitude = altitude;
this.x = x;
this.y = y;
this.z = z;
this.q = q;
this.approachX = approachX;
this.approachY = approachY;
this.approachZ = approachZ;
this.timeUsec = timeUsec;
}
private AttPosMocap(BigInteger timeUsec, List<Float> q, float x, float y, float z,
List<Float> covariance) {
this.timeUsec = timeUsec;
this.q = q;
this.x = x;
this.y = y;
this.z = z;
this.covariance = covariance;
}
/**
* Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
*/
@MavlinkFieldInfo(
position = 2,
unitSize = 4,
arraySize = 4,
description = "Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)"
)
public final List<Float> q() {
return this.q;
}
/**
* Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle
* (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the
* second ROW, etc.). If unknown, assign NaN value to first element in the array.
*/
@MavlinkFieldInfo(
position = 7,
unitSize = 4,
arraySize = 21,
extension = true,
description = "Row-major representation of a pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array."
)
public final List<Float> covariance() {
return this.covariance;
}
/**
* World to surface normal and heading transformation of the takeoff position. Used to indicate
* the heading and slope of the ground
*/
@MavlinkFieldInfo(
position = 8,
unitSize = 4,
arraySize = 4,
description = "World to surface normal and heading transformation of the takeoff position. Used to indicate the heading and slope of the ground"
)
public final List<Float> q() {
return this.q;
}
private VisionPositionEstimate(BigInteger usec, float x, float y, float z, float roll,
float pitch, float yaw, List<Float> covariance, int resetCounter) {
this.usec = usec;
this.x = x;
this.y = y;
this.z = z;
this.roll = roll;
this.pitch = pitch;
this.yaw = yaw;
this.covariance = covariance;
this.resetCounter = resetCounter;
}
/**
* Row-major representation of pose 6x6 cross-covariance matrix upper right triangle (states:
* x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second
* ROW, etc.). If unknown, assign NaN value to first element in the array.
*/
@MavlinkFieldInfo(
position = 9,
unitSize = 4,
arraySize = 21,
extension = true,
description = "Row-major representation of pose 6x6 cross-covariance matrix upper right triangle (states: x, y, z, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array."
)
public final List<Float> covariance() {
return this.covariance;
}
private AttitudeTarget(long timeBootMs, int typeMask, List<Float> q, float bodyRollRate,
float bodyPitchRate, float bodyYawRate, float thrust) {
this.timeBootMs = timeBootMs;
this.typeMask = typeMask;
this.q = q;
this.bodyRollRate = bodyRollRate;
this.bodyPitchRate = bodyPitchRate;
this.bodyYawRate = bodyYawRate;
this.thrust = thrust;
}
/**
* Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
*/
@MavlinkFieldInfo(
position = 3,
unitSize = 4,
arraySize = 4,
description = "Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)"
)
public final List<Float> q() {
return this.q;
}
/**
* X-coordinate of starting bezier point, set to NaN if not being used
*/
@MavlinkFieldInfo(
position = 4,
unitSize = 4,
arraySize = 5,
description = "X-coordinate of starting bezier point, set to NaN if not being used"
)
public final List<Float> posX() {
return this.posX;
}
/**
* Y-coordinate of starting bezier point, set to NaN if not being used
*/
@MavlinkFieldInfo(
position = 5,
unitSize = 4,
arraySize = 5,
description = "Y-coordinate of starting bezier point, set to NaN if not being used"
)
public final List<Float> posY() {
return this.posY;
}
/**
* Z-coordinate of starting bezier point, set to NaN if not being used
*/
@MavlinkFieldInfo(
position = 6,
unitSize = 4,
arraySize = 5,
description = "Z-coordinate of starting bezier point, set to NaN if not being used"
)
public final List<Float> posZ() {
return this.posZ;
}
/**
* Y-acceleration of waypoint, set to NaN if not being used
*/
@MavlinkFieldInfo(
position = 11,
unitSize = 4,
arraySize = 5,
description = "Y-acceleration of waypoint, set to NaN if not being used"
)
public final List<Float> accY() {
return this.accY;
}
/**
* {@inheritDoc}
*/
@Override
@NonNull
public BoxedTypesPrivateFieldsIgnoreNull mapFromCursor(@NonNull StorIOSQLite storIOSQLite, @NonNull Cursor cursor) {
Boolean field1 = null;
if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
}
Short field2 = null;
if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
field2 = cursor.getShort(cursor.getColumnIndex("field2"));
}
Integer field3 = null;
if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
field3 = cursor.getInt(cursor.getColumnIndex("field3"));
}
Long field4 = null;
if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
field4 = cursor.getLong(cursor.getColumnIndex("field4"));
}
Float field5 = null;
if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
}
Double field6 = null;
if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
}
BoxedTypesPrivateFieldsIgnoreNull object = new BoxedTypesPrivateFieldsIgnoreNull(field1, field2, field3, field4, field5, field6);
return object;
}
private GlobalVisionPositionEstimate(BigInteger usec, float x, float y, float z, float roll,
float pitch, float yaw, List<Float> covariance, int resetCounter) {
this.usec = usec;
this.x = x;
this.y = y;
this.z = z;
this.roll = roll;
this.pitch = pitch;
this.yaw = yaw;
this.covariance = covariance;
this.resetCounter = resetCounter;
}
/**
* Row-major representation of pose 6x6 cross-covariance matrix upper right triangle (states:
* x_global, y_global, z_global, roll, pitch, yaw; first six entries are the first ROW, next five
* entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array.
*/
@MavlinkFieldInfo(
position = 9,
unitSize = 4,
arraySize = 21,
extension = true,
description = "Row-major representation of pose 6x6 cross-covariance matrix upper right triangle (states: x_global, y_global, z_global, roll, pitch, yaw; first six entries are the first ROW, next five entries are the second ROW, etc.). If unknown, assign NaN value to first element in the array."
)
public final List<Float> covariance() {
return this.covariance;
}
private AttitudeQuaternionCov(BigInteger timeUsec, List<Float> q, float rollspeed,
float pitchspeed, float yawspeed, List<Float> covariance) {
this.timeUsec = timeUsec;
this.q = q;
this.rollspeed = rollspeed;
this.pitchspeed = pitchspeed;
this.yawspeed = yawspeed;
this.covariance = covariance;
}
/**
* Row-major representation of a 3x3 attitude covariance matrix (states: roll, pitch, yaw;
* first three entries are the first ROW, next three entries are the second row, etc.). If unknown,
* assign NaN value to first element in the array.
*/
@MavlinkFieldInfo(
position = 6,
unitSize = 4,
arraySize = 9,
description = "Row-major representation of a 3x3 attitude covariance matrix (states: roll, pitch, yaw; first three entries are the first ROW, next three entries are the second row, etc.). If unknown, assign NaN value to first element in the array."
)
public final List<Float> covariance() {
return this.covariance;
}