From 6a8e359fb2dc4949d3a589d2e5cf3f0da94ed928 Mon Sep 17 00:00:00 2001 From: Gabor Papp Date: Tue, 18 Dec 2018 22:23:32 +0100 Subject: [PATCH 1/3] Improving geom::Torus major, minor radius documentation --- include/cinder/GeomIo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/cinder/GeomIo.h b/include/cinder/GeomIo.h index 5438dcec4c..51fa5bd6aa 100644 --- a/include/cinder/GeomIo.h +++ b/include/cinder/GeomIo.h @@ -529,7 +529,7 @@ class CI_API Torus : public Source { Torus& twist( unsigned twist, float offset ) { mTwist = twist; mTwistOffset = offset; return *this; } //! Specifies the major and minor radius as a ratio (minor : major). Resulting torus will fit unit cube. Torus& ratio( float ratio ) { ratio = math::clamp( ratio ); mRadiusMajor = 1; mRadiusMinor = 1 - ratio; return *this; } - //! Specifies the major and minor radius separately. + //! Specifies the major and minor radius separately. \a major is the distance from the axis to the farthest point of the torus. \a minor is the distance between the axis and the center of the rotated circle. Torus& radius( float major, float minor ) { mRadiusMajor = math::max(0, major); mRadiusMinor = math::max(0, minor); return *this; } size_t getNumVertices() const override; @@ -1151,7 +1151,7 @@ class CI_API WireTorus : public WireSource { WireTorus& subdivisionsCircle( int subdiv ) { mNumSegments = math::max( 3, subdiv ); return *this; } //! Specifies the major and minor radius as a ratio (minor : major). Resulting torus will fit unit cube. WireTorus& ratio( float ratio ) { ratio = math::clamp( ratio ); mRadiusMajor = 1; mRadiusMinor = 1 - ratio; return *this; } - //! Specifies the major and minor radius separately. + //! Specifies the major and minor radius separately. \a major is the distance from the axis to the farthest point of the torus. \a minor is the distance between the axis and the center of the rotated circle. WireTorus& radius( float major, float minor ) { mRadiusMajor = math::max( 0, major ); mRadiusMinor = math::max( 0, minor ); return *this; } size_t getNumVertices() const override; From 83522d8ea57492ef0d53ff3a965040af59ba94ce Mon Sep 17 00:00:00 2001 From: Gabor Papp Date: Tue, 18 Dec 2018 22:28:49 +0100 Subject: [PATCH 2/3] Fixing geom::Torus::ratio() --- include/cinder/GeomIo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/cinder/GeomIo.h b/include/cinder/GeomIo.h index 51fa5bd6aa..6309bbd926 100644 --- a/include/cinder/GeomIo.h +++ b/include/cinder/GeomIo.h @@ -528,7 +528,7 @@ class CI_API Torus : public Source { //! Allows you to twist the torus along the ring. The \a offset is in radians. Torus& twist( unsigned twist, float offset ) { mTwist = twist; mTwistOffset = offset; return *this; } //! Specifies the major and minor radius as a ratio (minor : major). Resulting torus will fit unit cube. - Torus& ratio( float ratio ) { ratio = math::clamp( ratio ); mRadiusMajor = 1; mRadiusMinor = 1 - ratio; return *this; } + Torus& ratio( float ratio ) { ratio = math::clamp( ratio ); mRadiusMajor = 1; mRadiusMinor = ratio; return *this; } //! Specifies the major and minor radius separately. \a major is the distance from the axis to the farthest point of the torus. \a minor is the distance between the axis and the center of the rotated circle. Torus& radius( float major, float minor ) { mRadiusMajor = math::max(0, major); mRadiusMinor = math::max(0, minor); return *this; } @@ -1150,7 +1150,7 @@ class CI_API WireTorus : public WireSource { //! Specifies the number of segments that make up each circle. Defaults to \c 72. WireTorus& subdivisionsCircle( int subdiv ) { mNumSegments = math::max( 3, subdiv ); return *this; } //! Specifies the major and minor radius as a ratio (minor : major). Resulting torus will fit unit cube. - WireTorus& ratio( float ratio ) { ratio = math::clamp( ratio ); mRadiusMajor = 1; mRadiusMinor = 1 - ratio; return *this; } + WireTorus& ratio( float ratio ) { ratio = math::clamp( ratio ); mRadiusMajor = 1; mRadiusMinor = ratio; return *this; } //! Specifies the major and minor radius separately. \a major is the distance from the axis to the farthest point of the torus. \a minor is the distance between the axis and the center of the rotated circle. WireTorus& radius( float major, float minor ) { mRadiusMajor = math::max( 0, major ); mRadiusMinor = math::max( 0, minor ); return *this; } From 146d2ba2834417ab2fdbccf3442cbd79be98125d Mon Sep 17 00:00:00 2001 From: Gabor Papp Date: Tue, 18 Dec 2018 23:06:17 +0100 Subject: [PATCH 3/3] Adding geom::Torus radiusCentered method --- include/cinder/GeomIo.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/cinder/GeomIo.h b/include/cinder/GeomIo.h index 6309bbd926..02d04de554 100644 --- a/include/cinder/GeomIo.h +++ b/include/cinder/GeomIo.h @@ -531,6 +531,8 @@ class CI_API Torus : public Source { Torus& ratio( float ratio ) { ratio = math::clamp( ratio ); mRadiusMajor = 1; mRadiusMinor = ratio; return *this; } //! Specifies the major and minor radius separately. \a major is the distance from the axis to the farthest point of the torus. \a minor is the distance between the axis and the center of the rotated circle. Torus& radius( float major, float minor ) { mRadiusMajor = math::max(0, major); mRadiusMinor = math::max(0, minor); return *this; } + //! Sets the radii for a torus that is generated by revolving a small circle of radius \a r along the axis made by a bigger circle of radius \a R. + Torus& radiusCentered( float R, float r ) { mRadiusMajor = math::max(0, R + r); mRadiusMinor = math::max(0, R); return *this; } size_t getNumVertices() const override; size_t getNumIndices() const override; @@ -1153,6 +1155,8 @@ class CI_API WireTorus : public WireSource { WireTorus& ratio( float ratio ) { ratio = math::clamp( ratio ); mRadiusMajor = 1; mRadiusMinor = ratio; return *this; } //! Specifies the major and minor radius separately. \a major is the distance from the axis to the farthest point of the torus. \a minor is the distance between the axis and the center of the rotated circle. WireTorus& radius( float major, float minor ) { mRadiusMajor = math::max( 0, major ); mRadiusMinor = math::max( 0, minor ); return *this; } + //! Sets the radii for a torus that is generated by revolving a small circle of radius \a r along the axis made by a bigger circle of radius \a R. + WireTorus& radiusCentered( float R, float r ) { mRadiusMajor = math::max(0, R + r); mRadiusMinor = math::max(0, R); return *this; } size_t getNumVertices() const override; void loadInto( Target *target, const AttribSet &requestedAttribs ) const override;