-
Notifications
You must be signed in to change notification settings - Fork 70
Support for the real projective plane #1405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
geometry/geometry.vcxproj
Outdated
@@ -292,6 +292,8 @@ | |||
<ClInclude Include="named_quantities.hpp" /> | |||
<ClInclude Include="pair.hpp" /> | |||
<ClInclude Include="pair_body.hpp" /> | |||
<ClInclude Include="perspective.hpp" /> | |||
<ClInclude Include="perspective_body.hpp" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove nonexistent files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/r3_element.hpp
Outdated
struct enable_if_normed<R3Element<T, T, T>> : not_constructible { | ||
using Scalar = T; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a type alias (norm_type<T>
or somesuch) for typename enable_if_normed<T>::Scalar
, and use it below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OBE.
geometry/r3_projective.hpp
Outdated
// the points at infinity. Note that this identification is not unique, so | ||
// the comparison of the values returned by this function is not an | ||
// equivalence on the projective plane. | ||
double point_at_infinity() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document that this must be at infinity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, just remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/r3_projective.hpp
Outdated
// equivalence on the projective plane. | ||
double point_at_infinity() const; | ||
|
||
// Returns the Euclidean (non-homegeneous) coordinates of the point. May be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inhomogeneous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
homoiousios.
geometry/r3_projective_body.hpp
Outdated
R3Projective<Scalar>::R3Projective( | ||
R3Element<Scalar, Scalar, double> const& coordinates) | ||
: coordinates_(coordinates) { | ||
// (0, 0, 0) does not represent any point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[0:0:0]
geometry/r3_projective_body.hpp
Outdated
|
||
template<typename Scalar> | ||
std::string DebugString(R3Projective<Scalar> const & r3_projective) { | ||
return DebugString(r3_projective.coordinates_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the notation [x:y:z]
, it is fairly unambiguous (which is rare enough), and it will allow us to distinguish homogeneous coordinates from vectors. See https://en.wikipedia.org/wiki/Projective_space#Projective_space_as_a_manifold.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/r3_projective.hpp
Outdated
// must be a 1-dimensional vector space over ℝ, typically represented by | ||
// |Quantity| or |double|. | ||
template<typename Scalar> | ||
class R3Projective { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R2Projective
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RP2Element
.
geometry/r3_element.hpp
Outdated
// is also normed. | ||
// |R3Element| is the underlying data type for more advanced strongly typed | ||
// structures such as |Multivector|. | ||
template<typename ScalarX, typename ScalarY, typename ScalarZ> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, let's not go there, we're not using the vector space structure in the projective plane.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/rp2_element_body.hpp
Outdated
template<typename Scalar> | ||
Scalar const RP2Element<Scalar>::x() const { | ||
if (x_ == Scalar() && z_ == 0.0) { | ||
return Infinity<Scalar>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This infinity should have the sign of x_
, since z_
is always positive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/rp2_element_body.hpp
Outdated
template<typename Scalar> | ||
Scalar const RP2Element<Scalar>::y() const { | ||
if (y_ == Scalar() && z_ == 0.0) { | ||
return Infinity<Scalar>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/rp2_element_body.hpp
Outdated
Scalar const& x, Scalar const& y, double z) | ||
: x_(x), y_(y), z_(z) { | ||
// [0:0:0] does not represent any point. | ||
CHECK(x != Scalar() || y != Scalar() || z != 0.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am skeptical; [underflow:underflow:underflow] should probably not cause an outright failure...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, removing that check will do the job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/rp2_element.hpp
Outdated
bool is_at_infinity() const; | ||
|
||
// Returns the Euclidean (inhomogeneous) coordinates of the point. May be | ||
// infinities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the semantics: the signs of (x,y) will be in the quadrant determined by the signs of x and y, and both will be infinite or none.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
geometry/rp2_element.hpp
Outdated
public: | ||
// Constructs a point from a set of homogeneous coordinates. The | ||
// coordinates may not all be zero. | ||
explicit RP2Element(Scalar const& x, Scalar const& y, double z); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the semantics: this class handles underflows gracefully, and behaves as if taking the limit z->0 before the limit of x and y.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
os << DebugString(rp2_element); | ||
return os; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some tests with signed 0s exercising the aforementioned behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
No description provided.