Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions bindings/python/src/geometry/basic_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
.def( pybind11::init< const Point< dimension >&, \
const Point< dimension >& >() ) \
.def( "direction", &Segment##dimension##D::direction ) \
.def( "normalized_direction", \
&Segment##dimension##D::normalized_direction ) \
.def( "barycenter", &Segment##dimension##D::barycenter ) \
.def( "length", &Segment##dimension##D::length ) \
.def( "vertices", &Segment##dimension##D::vertices ) \
Expand Down
1 change: 0 additions & 1 deletion include/geode/geometry/basic_objects/segment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
namespace geode
{
template < typename PointType, index_t dimension >
class GenericSegment

Check warning on line 42 in include/geode/geometry/basic_objects/segment.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/geometry/basic_objects/segment.hpp:42:11 [cppcoreguidelines-special-member-functions]

class 'GenericSegment' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
{
public:
static constexpr auto dim = dimension;
Expand All @@ -56,7 +56,6 @@
GenericSegment< PointType, dimension >&& other ) noexcept;

[[nodiscard]] Vector< dimension > direction() const;
[[nodiscard]] Vector< dimension > normalized_direction() const;
[[nodiscard]] Point< dimension > barycenter() const;
[[nodiscard]] double length() const;
void set_point( local_index_t vertex, PointType point );
Expand All @@ -70,7 +69,7 @@
};

template < index_t dimension >
class OwnerSegment : public GenericSegment< Point< dimension >, dimension >

Check warning on line 72 in include/geode/geometry/basic_objects/segment.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/geometry/basic_objects/segment.hpp:72:11 [cppcoreguidelines-special-member-functions]

class 'OwnerSegment' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
{
using Base = GenericSegment< Point< dimension >, dimension >;

Expand All @@ -88,7 +87,7 @@
ALIAS_1D_AND_2D_AND_3D( OwnerSegment );

template < index_t dimension >
class Segment : public GenericSegment< RefPoint< dimension >, dimension >

Check warning on line 90 in include/geode/geometry/basic_objects/segment.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/geometry/basic_objects/segment.hpp:90:11 [cppcoreguidelines-special-member-functions]

class 'Segment' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
{
using Base = GenericSegment< RefPoint< dimension >, dimension >;

Expand All @@ -97,7 +96,7 @@
const Point< dimension >& point1 ) noexcept;

Segment( const Segment< dimension >& other ) noexcept;
Segment( const OwnerSegment< dimension >& other ) noexcept;

Check warning on line 99 in include/geode/geometry/basic_objects/segment.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/geometry/basic_objects/segment.hpp:99:9 [google-explicit-constructor]

single-argument constructors must be marked explicit to avoid unintentional implicit conversions
Segment< dimension >& operator=(
const Segment< dimension >& other ) noexcept;
Segment( Segment< dimension >&& other ) noexcept;
Expand Down
5 changes: 2 additions & 3 deletions src/geode/geometry/barycentric_coordinates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
const Point3D& point, const Tetrahedron& tetra )
{
const auto& vertices = tetra.vertices();
const Vector3D v0{ vertices[0], vertices[1] };

Check warning on line 38 in src/geode/geometry/barycentric_coordinates.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/barycentric_coordinates.cpp:38:24 [readability-identifier-length]

variable name 'v0' is too short, expected at least 3 characters
const Vector3D v1{ vertices[0], vertices[2] };

Check warning on line 39 in src/geode/geometry/barycentric_coordinates.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/barycentric_coordinates.cpp:39:24 [readability-identifier-length]

variable name 'v1' is too short, expected at least 3 characters
const Vector3D v2{ vertices[0], vertices[3] };

Check warning on line 40 in src/geode/geometry/barycentric_coordinates.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/barycentric_coordinates.cpp:40:24 [readability-identifier-length]

variable name 'v2' is too short, expected at least 3 characters
const Vector3D v3{ vertices[0], point };

Check warning on line 41 in src/geode/geometry/barycentric_coordinates.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/barycentric_coordinates.cpp:41:24 [readability-identifier-length]

variable name 'v3' is too short, expected at least 3 characters
const auto a = v0.dot( v3 );

Check warning on line 42 in src/geode/geometry/barycentric_coordinates.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/barycentric_coordinates.cpp:42:20 [readability-identifier-length]

variable name 'a' is too short, expected at least 3 characters
const auto b = v0.dot( v0 );

Check warning on line 43 in src/geode/geometry/barycentric_coordinates.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/barycentric_coordinates.cpp:43:20 [readability-identifier-length]

variable name 'b' is too short, expected at least 3 characters
const auto c = v0.dot( v1 );
const auto d = v0.dot( v2 );
const auto e = v1.dot( v3 );
Expand Down Expand Up @@ -172,12 +172,11 @@
const Point< dimension >& point, const Segment< dimension >& segment )
{
const auto dir = segment.direction();
const auto length = dir.length();
const auto& vertices = segment.vertices();
const Vector< dimension > v0p{ vertices[0], point };
const auto dot0 = v0p.dot( dir ) / length;
const auto dot0 = v0p.dot( dir );
const Vector< dimension > v1p{ vertices[1], point };
const auto dot1 = -v1p.dot( dir ) / length;
const auto dot1 = -v1p.dot( dir );
const auto sum = dot0 + dot1;
OpenGeodeGeometryException::check_exception( sum != 0, point,
OpenGeodeException::TYPE::data,
Expand Down
2 changes: 1 addition & 1 deletion src/geode/geometry/basic_objects/infinite_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace geode
template < typename PointType, index_t dimension >
GenericLine< PointType, dimension >::GenericLine(
const Segment< dimension >& segment )
: GenericLine( segment.normalized_direction(), segment.vertices()[0] )
: GenericLine( segment.direction(), segment.vertices()[0] )
{
}
template < typename PointType, index_t dimension >
Expand Down
9 changes: 2 additions & 7 deletions src/geode/geometry/basic_objects/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,9 @@ namespace geode
OpenGeodeException::TYPE::data,
"[Segment::direction] Segment length too small (",
direction.length(), ")" );
return direction;
}
template < typename PointType, index_t dimension >
Vector< dimension >
GenericSegment< PointType, dimension >::normalized_direction() const
{
return direction().normalize();
return direction.normalize();
}

template < typename PointType, index_t dimension >
Point< dimension >
GenericSegment< PointType, dimension >::barycenter() const
Expand Down
2 changes: 1 addition & 1 deletion src/geode/geometry/bounding_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace
const auto box_extent = box.diagonal() / 2.;
const auto segment_origin = segment.barycenter() - box.center();
const auto segment_extent = segment.length() / 2.;
const auto segment_direction = segment.normalized_direction();
const auto segment_direction = segment.direction();
for( const auto i : geode::LRange{ dimension } )
{
const auto lhs = std::fabs( segment_origin.value( i ) );
Expand Down
11 changes: 7 additions & 4 deletions src/geode/geometry/distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,10 @@ namespace
/* Algorithm and code found on
* https://github.com/davideberly/GeometricTools/blob/master/GTE/Mathematics/DistSegmentSegment.h
*/
const auto P1mP0 = segment0.direction();
const auto Q1mQ0 = segment1.direction();
const geode::Vector< dimension > P1mP0{ segment0.vertices()[0],
segment0.vertices()[1] };
const geode::Vector< dimension > Q1mQ0{ segment1.vertices()[0],
segment1.vertices()[1] };
const geode::Vector< dimension > P0mQ0{ segment1.vertices()[0],
segment0.vertices()[0] };
const auto a = P1mP0.dot( P1mP0 );
Expand Down Expand Up @@ -799,7 +801,7 @@ namespace
auto step = longest_segment.length() / 2;
auto current_distance =
geode::point_segment_distance( current_point, shortest_segment );
const auto segment_direction = longest_segment.normalized_direction();
const auto segment_direction = longest_segment.direction();
while( step > geode::GLOBAL_EPSILON )
{
const auto point_at_step_plus =
Expand Down Expand Up @@ -898,7 +900,8 @@ namespace geode
segment_line_distance( const Segment< dimension >& segment,
const InfiniteLine< dimension >& line )
{
const auto segDirection = segment.direction();
const Vector< dimension > segDirection{ segment.vertices()[0],
segment.vertices()[1] };
const Vector< dimension > diff{ segment.vertices()[0], line.origin() };
const auto a00 = line.direction().dot( line.direction() );
const auto a01 = -line.direction().dot( segDirection );
Expand Down
7 changes: 3 additions & 4 deletions src/geode/geometry/intersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ namespace geode
// |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))
// |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))
// |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)
const auto segment_normalized_direction =
segment.normalized_direction();
const auto segment_normalized_direction = segment.direction();
auto d_dot_n = segment_normalized_direction.dot( normal );
signed_index_t sign;
if( d_dot_n > 0. )
Expand Down Expand Up @@ -538,7 +537,7 @@ namespace geode
// is x^2 + y^2 = r^2, where r is the cylinder radius. The end
// caps are |z| = h/2, where h is the cylinder height.
const auto basis =
compute_orthogonal_basis( cylinder.axis().normalized_direction() );
compute_orthogonal_basis( cylinder.axis().direction() );
const auto& W = basis[0];
const auto& U = basis[1];
const auto& V = basis[2];
Expand Down Expand Up @@ -796,7 +795,7 @@ namespace geode
{
const geode::Vector3D point_to_vertex{ results[r],
cylinder.axis().vertices()[v] };
if( cylinder.axis().normalized_direction().dot(
if( cylinder.axis().direction().dot(
point_to_vertex.normalize() )
<= GLOBAL_EPSILON )
{
Expand Down
2 changes: 1 addition & 1 deletion src/geode/geometry/projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace geode
{
return barycenter;
}
const auto norm_dir = segment.direction() / length;
const auto norm_dir = segment.direction();
const auto d = norm_dir.dot( { barycenter, point } );
if( std::fabs( d ) <= length / 2. )
{
Expand Down
14 changes: 8 additions & 6 deletions src/geode/mesh/helpers/rasterize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,12 @@ namespace
const auto& vertices = triangle_in_grid.vertices();
for( const auto e : geode::LRange{ 3 } )
{
result[e].first = geode::Vector2D{
{ -1 * edges_in_grid[e].direction().value( plane_axes[1] ),
edges_in_grid[e].direction().value( plane_axes[0] ) }
} * normal_orientation;
result[e].first =
geode::Vector2D{
{ -1 * edges_in_grid[e].direction().value( plane_axes[1] ),
edges_in_grid[e].direction().value( plane_axes[0] ) }
}
* normal_orientation * edges_in_grid[e].length();
const auto& vertex = vertices[e];
result[e].second = -result[e].first.dot( geode::Vector2D{
{ vertex.value( plane_axes[0] ),
Expand Down Expand Up @@ -564,8 +566,8 @@ namespace
const auto pt1_in_grid =
grid.grid_coordinate_system().coordinates( seg_vertices[1] );
const geode::Segment2D segment_in_grid{ pt0_in_grid, pt1_in_grid };
const auto normal_in_grid =
geode::perpendicular( segment_in_grid.direction() );
const auto normal_in_grid = geode::perpendicular(
segment_in_grid.direction() * segment_in_grid.length() );
const geode::InfiniteLine2D line_in_grid{ segment_in_grid };
const auto critical_point = compute_critical_point( normal_in_grid );

Expand Down
Loading