[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kig] objects: Orientability of Arcs can now be made to good use in order to avoid abrupt
From:       Maurizio Paolini <paolini () dmf ! unicatt ! it>
Date:       2016-04-10 14:48:08
Message-ID: E1apGem-0000LU-DW () scm ! kde ! org
[Download RAW message or body]

Git commit d868f2d47d9ae0b4d33b62704683e8dbb00aba59 by Maurizio Paolini.
Committed on 04/04/2016 at 15:56.
Pushed by paolini into branch 'master'.

Orientability of Arcs can now be made to good use in order to avoid abrupt
jumps of some objects constructed from them: first and second end-points;
constructions depending on the parametrization.
This is mainly the case for arcs by 3 points when the concavity changes.

M  +8    -2    objects/other_imp.cc

http://commits.kde.org/kig/d868f2d47d9ae0b4d33b62704683e8dbb00aba59

diff --git a/objects/other_imp.cc b/objects/other_imp.cc
index 7bc143e..0880d29 100644
--- a/objects/other_imp.cc
+++ b/objects/other_imp.cc
@@ -517,11 +517,13 @@ double ArcImp::getParam( const Coordinate& c, const \
KigDocument& ) const  //
   angle = max( 0., min( angle, ma ) );
   angle /= ma;
+  if ( mradius < 0 ) angle = 1.0 - angle;  // this is to avoid abrupt jumps when an \
ArcBTPType changes concavity  return angle;
 }
 
 const Coordinate ArcImp::getPoint( double p, const KigDocument& ) const
 {
+  if ( mradius < 0 ) p = 1.0 - p;  // this is to avoid abrupt jumps when an \
ArcBTPType changes concavity  double angle = msa + p * ma;
   Coordinate d = Coordinate( cos( angle ), sin( angle ) ) * fabs( mradius );
   return mcenter + d;
@@ -554,13 +556,17 @@ double ArcImp::angle() const
 
 Coordinate ArcImp::firstEndPoint() const
 {
-  double angle = msa;
+  /**
+   * mp: We take advantage of the arc orientation (mainly for the benefit of arc \
through 3 points) +   * in order to avoid abrupt jumps when moving points
+   */
+  const double angle = mradius >= 0 ? msa : msa+ma;
   return mcenter + Coordinate( cos( angle ), sin( angle ) ) * fabs( mradius );
 }
 
 Coordinate ArcImp::secondEndPoint() const
 {
-  double angle = msa + ma;
+  const double angle = mradius >= 0 ? msa+ma : msa;
   return mcenter + Coordinate( cos( angle ), sin( angle ) ) * fabs( mradius );
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic