Skip to content

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

Merged
merged 15 commits into from
May 27, 2017

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented May 27, 2017

No description provided.

@@ -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" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove nonexistent files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

struct enable_if_normed<R3Element<T, T, T>> : not_constructible {
using Scalar = T;
};

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OBE.

// 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;
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// equivalence on the projective plane.
double point_at_infinity() const;

// Returns the Euclidean (non-homegeneous) coordinates of the point. May be
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inhomogeneous?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

homoiousios.

R3Projective<Scalar>::R3Projective(
R3Element<Scalar, Scalar, double> const& coordinates)
: coordinates_(coordinates) {
// (0, 0, 0) does not represent any point.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[0:0:0]


template<typename Scalar>
std::string DebugString(R3Projective<Scalar> const & r3_projective) {
return DebugString(r3_projective.coordinates_);
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// must be a 1-dimensional vector space over ℝ, typically represented by
// |Quantity| or |double|.
template<typename Scalar>
class R3Projective {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R2Projective

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RP2Element.

// 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>
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

template<typename Scalar>
Scalar const RP2Element<Scalar>::x() const {
if (x_ == Scalar() && z_ == 0.0) {
return Infinity<Scalar>();
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

template<typename Scalar>
Scalar const RP2Element<Scalar>::y() const {
if (y_ == Scalar() && z_ == 0.0) {
return Infinity<Scalar>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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);
Copy link
Member

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...

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

bool is_at_infinity() const;

// Returns the Euclidean (inhomogeneous) coordinates of the point. May be
// infinities.
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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);
Copy link
Member

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.

Copy link
Member Author

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;
}

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@eggrobin eggrobin added the LGTM label May 27, 2017
@eggrobin eggrobin merged commit 625c6b9 into mockingbirdnest:master May 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants