Simplify Point, Translation and Scale Debug output
This commit is contained in:
parent
49e3633c1c
commit
65e90d53a9
@ -1993,7 +1993,10 @@ impl_fmt!(fmt::Binary, "{:b}", "{:.1$b}");
|
|||||||
impl_fmt!(fmt::Pointer, "{:p}", "{:.1$p}");
|
impl_fmt!(fmt::Pointer, "{:p}", "{:.1$p}");
|
||||||
|
|
||||||
/// Displays a vector using commas as the delimiter
|
/// Displays a vector using commas as the delimiter
|
||||||
pub fn display_column_vec_as_row<T: Scalar + fmt::Display, D: crate::DimName>(vector: &OVector<T, D>, f: &mut fmt::Formatter<'_>) -> fmt::Result
|
pub fn format_column_vec_as_row<T: Scalar + fmt::Display, D: crate::DimName>(
|
||||||
|
vector: &OVector<T, D>,
|
||||||
|
f: &mut fmt::Formatter<'_>,
|
||||||
|
) -> fmt::Result
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, D>,
|
DefaultAllocator: Allocator<T, D>,
|
||||||
{
|
{
|
||||||
|
@ -952,7 +952,7 @@ impl<T: RealField> Default for UnitDualQuaternion<T> {
|
|||||||
impl<T: RealField + fmt::Display> fmt::Display for UnitDualQuaternion<T> {
|
impl<T: RealField + fmt::Display> fmt::Display for UnitDualQuaternion<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{{ translation: ")?;
|
write!(f, "{{ translation: ")?;
|
||||||
crate::display_column_vec_as_row(&self.translation().vector, f)?;
|
crate::format_column_vec_as_row(&self.translation().vector, f)?;
|
||||||
write!(f, ", ")?;
|
write!(f, ", ")?;
|
||||||
write!(f, "rotation: ")?;
|
write!(f, "rotation: ")?;
|
||||||
std::fmt::Display::fmt(&self.rotation(), f)?;
|
std::fmt::Display::fmt(&self.rotation(), f)?;
|
||||||
|
@ -549,7 +549,7 @@ where
|
|||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{{ translation: ")?;
|
write!(f, "{{ translation: ")?;
|
||||||
crate::display_column_vec_as_row(&self.translation.vector, f)?;
|
crate::format_column_vec_as_row(&self.translation.vector, f)?;
|
||||||
write!(f, ", ")?;
|
write!(f, ", ")?;
|
||||||
write!(f, "rotation: ")?;
|
write!(f, "rotation: ")?;
|
||||||
std::fmt::Display::fmt(&self.rotation, f)?;
|
std::fmt::Display::fmt(&self.rotation, f)?;
|
||||||
|
@ -35,7 +35,7 @@ use std::mem::MaybeUninit;
|
|||||||
/// may have some other methods, e.g., `isometry.inverse_transform_point(&point)`. See the documentation
|
/// may have some other methods, e.g., `isometry.inverse_transform_point(&point)`. See the documentation
|
||||||
/// of said transformations for details.
|
/// of said transformations for details.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||||
@ -49,6 +49,15 @@ where
|
|||||||
pub coords: OVector<T, D>,
|
pub coords: OVector<T, D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Scalar + fmt::Debug, D: DimName> fmt::Debug for OPoint<T, D>
|
||||||
|
where
|
||||||
|
DefaultAllocator: Allocator<T, D>,
|
||||||
|
{
|
||||||
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
|
self.coords.as_slice().fmt(formatter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Scalar + hash::Hash, D: DimName> hash::Hash for OPoint<T, D>
|
impl<T: Scalar + hash::Hash, D: DimName> hash::Hash for OPoint<T, D>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, D>,
|
DefaultAllocator: Allocator<T, D>,
|
||||||
@ -458,7 +467,7 @@ where
|
|||||||
/// ```
|
/// ```
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
crate::display_column_vec_as_row(&self.coords, f)
|
crate::format_column_vec_as_row(&self.coords, f)
|
||||||
} else {
|
} else {
|
||||||
std::fmt::Display::fmt(&self.coords, f) // pretty-prints vector
|
std::fmt::Display::fmt(&self.coords, f) // pretty-prints vector
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,19 @@ use crate::geometry::Point;
|
|||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Scale<T, const D: usize> {
|
pub struct Scale<T, const D: usize> {
|
||||||
/// The scale coordinates, i.e., how much is multiplied to a point's coordinates when it is
|
/// The scale coordinates, i.e., how much is multiplied to a point's coordinates when it is
|
||||||
/// scaled.
|
/// scaled.
|
||||||
pub vector: SVector<T, D>,
|
pub vector: SVector<T, D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: fmt::Debug, const D: usize> fmt::Debug for Scale<T, D> {
|
||||||
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
|
self.vector.as_slice().fmt(formatter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Scalar + hash::Hash, const D: usize> hash::Hash for Scale<T, D>
|
impl<T: Scalar + hash::Hash, const D: usize> hash::Hash for Scale<T, D>
|
||||||
where
|
where
|
||||||
Owned<T, Const<D>>: hash::Hash,
|
Owned<T, Const<D>>: hash::Hash,
|
||||||
@ -364,7 +370,7 @@ where
|
|||||||
impl<T: Scalar + fmt::Display, const D: usize> fmt::Display for Scale<T, D> {
|
impl<T: Scalar + fmt::Display, const D: usize> fmt::Display for Scale<T, D> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
crate::display_column_vec_as_row(&self.vector, f)
|
crate::format_column_vec_as_row(&self.vector, f)
|
||||||
} else {
|
} else {
|
||||||
std::fmt::Display::fmt(&self.vector, f) // pretty-prints vector
|
std::fmt::Display::fmt(&self.vector, f) // pretty-prints vector
|
||||||
}
|
}
|
||||||
|
@ -398,7 +398,7 @@ where
|
|||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{{ translation: ")?;
|
write!(f, "{{ translation: ")?;
|
||||||
crate::display_column_vec_as_row(&self.isometry.translation.vector, f)?;
|
crate::format_column_vec_as_row(&self.isometry.translation.vector, f)?;
|
||||||
write!(f, ", ")?;
|
write!(f, ", ")?;
|
||||||
write!(f, "rotation: ")?;
|
write!(f, "rotation: ")?;
|
||||||
std::fmt::Display::fmt(&self.isometry.rotation, f)?;
|
std::fmt::Display::fmt(&self.isometry.rotation, f)?;
|
||||||
|
@ -23,13 +23,19 @@ use crate::geometry::Point;
|
|||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Translation<T, const D: usize> {
|
pub struct Translation<T, const D: usize> {
|
||||||
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is
|
/// The translation coordinates, i.e., how much is added to a point's coordinates when it is
|
||||||
/// translated.
|
/// translated.
|
||||||
pub vector: SVector<T, D>,
|
pub vector: SVector<T, D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: fmt::Debug, const D: usize> fmt::Debug for Translation<T, D> {
|
||||||
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
|
self.vector.as_slice().fmt(formatter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Scalar + hash::Hash, const D: usize> hash::Hash for Translation<T, D>
|
impl<T: Scalar + hash::Hash, const D: usize> hash::Hash for Translation<T, D>
|
||||||
where
|
where
|
||||||
Owned<T, Const<D>>: hash::Hash,
|
Owned<T, Const<D>>: hash::Hash,
|
||||||
@ -279,7 +285,7 @@ where
|
|||||||
impl<T: Scalar + fmt::Display, const D: usize> fmt::Display for Translation<T, D> {
|
impl<T: Scalar + fmt::Display, const D: usize> fmt::Display for Translation<T, D> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
crate::display_column_vec_as_row(&self.vector, f)
|
crate::format_column_vec_as_row(&self.vector, f)
|
||||||
} else {
|
} else {
|
||||||
std::fmt::Display::fmt(&self.vector, f) // pretty-prints vector
|
std::fmt::Display::fmt(&self.vector, f) // pretty-prints vector
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user