use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};
#[derive(Clone, Debug, ArrowField, ArrowSerialize, ArrowDeserialize, PartialEq)]
pub struct Point2D {
pub x: f32,
pub y: f32,
}
impl Point2D {
pub const ZERO: Point2D = Point2D { x: 0.0, y: 0.0 };
#[inline]
pub fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}
impl re_log_types::LegacyComponent for Point2D {
#[inline]
fn legacy_name() -> re_log_types::ComponentName {
"rerun.point2d".into()
}
}
impl From<[f32; 2]> for Point2D {
#[inline]
fn from(p: [f32; 2]) -> Self {
Self { x: p[0], y: p[1] }
}
}
#[cfg(feature = "glam")]
impl From<glam::Vec2> for Point2D {
#[inline]
fn from(pt: glam::Vec2) -> Self {
Self::new(pt.x, pt.y)
}
}
#[cfg(feature = "glam")]
impl From<Point2D> for glam::Vec2 {
#[inline]
fn from(pt: Point2D) -> Self {
Self::new(pt.x, pt.y)
}
}
#[cfg(feature = "glam")]
impl From<Point2D> for glam::Vec3 {
#[inline]
fn from(pt: Point2D) -> Self {
Self::new(pt.x, pt.y, 0.0)
}
}
re_log_types::component_legacy_shim!(Point2D);
#[derive(Clone, Debug, ArrowField, ArrowSerialize, ArrowDeserialize, PartialEq)]
pub struct Point3D {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl Point3D {
pub const ZERO: Point3D = Point3D {
x: 0.0,
y: 0.0,
z: 0.0,
};
#[inline]
pub fn new(x: f32, y: f32, z: f32) -> Self {
Self { x, y, z }
}
}
impl re_log_types::LegacyComponent for Point3D {
#[inline]
fn legacy_name() -> re_log_types::ComponentName {
"rerun.point3d".into()
}
}
impl From<[f32; 3]> for Point3D {
#[inline]
fn from(p: [f32; 3]) -> Self {
Self {
x: p[0],
y: p[1],
z: p[2],
}
}
}
#[cfg(feature = "glam")]
impl From<glam::Vec3> for Point3D {
#[inline]
fn from(pt: glam::Vec3) -> Self {
Self::new(pt.x, pt.y, pt.z)
}
}
#[cfg(feature = "glam")]
impl From<Point3D> for glam::Vec3 {
#[inline]
fn from(pt: Point3D) -> Self {
Self::new(pt.x, pt.y, pt.z)
}
}
re_log_types::component_legacy_shim!(Point3D);