Skip to content

Commit

Permalink
update MULTI_POINT_LINE.
Browse files Browse the repository at this point in the history
  • Loading branch information
changgang committed Mar 7, 2024
1 parent 436f0f3 commit c4f9938
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions code/steps/source/basic/multi_point_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void MULTI_POINT_LINE::clear()
{
for(unsigned int i=0; i<STEPS_MAX_MULTI_POINT_LINE_SIZE; ++i)
{
line[i][0] = 0.0;
line[i][1] = 0.0;
line[i][0] = INFINITE_THRESHOLD;
line[i][1] = INFINITE_THRESHOLD;
}
}

Expand Down Expand Up @@ -77,7 +77,7 @@ unsigned int MULTI_POINT_LINE::get_valid_point_size() const
unsigned int valid_point_count = STEPS_MAX_MULTI_POINT_LINE_SIZE;
for(unsigned int i=0; i<STEPS_MAX_MULTI_POINT_LINE_SIZE; ++i)
{
if(line[i][0]==0.0)
if(fabs(line[i][0]-INFINITE_THRESHOLD)<DOUBLE_EPSILON and fabs(line[i][1]-INFINITE_THRESHOLD)<DOUBLE_EPSILON)
{
valid_point_count = i;
break;
Expand Down Expand Up @@ -159,8 +159,10 @@ void MULTI_POINT_LINE::reorder_points()
double MULTI_POINT_LINE::get_y_at_x(double x)
{
unsigned int n = get_valid_point_size();
if(n<2)
if(n<1)
return 0.0;
if(n==1)
return get_point_y_with_index(0);

unsigned int i_less = get_the_last_point_with_x_less_than_or_equal_to(x);
if(i_less==INDEX_NOT_EXIST)
Expand Down

0 comments on commit c4f9938

Please sign in to comment.