From: Johan E. <jbc...@sw...> - 2012-10-20 11:50:50
|
On 20-10-2012 13:26, Jabiertxo Arraiza Cenoz wrote: > Solved (Find the second handle position (p2) ): > Geom_::Curve foo = ... > Geom::Point p2 = ?; > if (foo) { > Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const *>( foo ); > if ( cubic && (*cubic)[2] != (*cubic)[3] ){ > p2 = (*cubic1)[2]; > } > } > Hi to all > > For find symmetric handle node I use this > Where g3 is the end node of previous curve and (*cubic1)[2] his second handle position. > (g0-(*penultimateGreenCubic)[2]) + g0 > Geom::Point symmhandle =(g3-(*cubic1)[2]) + g3; > Hi to all and sorry for repost Hello Jabiertxo, Although I do not understand completely what you are trying to compute, I can give you an important tip to improve your code. In most cases you should not do a direct floating point comparison. "(*cubic)[2] != (*cubic)[3]" will only evaluate to 'false' if both point are exactly the same (binary equivalent). Due to numerical errors, this is almost never the case, even if you think they should be the same. For example, "1.0/3.0 * 3.0 == 1.0" may evaluate to 'false'. Instead, you should use "Geom::are_near" to compare whether points or coordinates are the same or not. So "(*cubic)[2] != (*cubic)[3]" ---> "!are_near((*cubic)[2], (*cubic)[3])" Ciao, Johan |