Lines Lifted from Anchor, is'nt it?
If t=0, something happened.
vCurveCalculation.cpp Mon Dec 30 19:04:22 2019 1 :#include2 :#include 3 :#include // ADD: 20191230 4 : 5 :#include "array_counter.h" // ADD: 20191230 6 :#include "sender.h" // ADD: 20191230 7 :#include "Print.h" // ADD: 20191230 8 : 9 :#include "vPoint.h" 10 :#include "vLine.h" 11 :#include "vCalculation.h" 12 :#include "vCurveCalculation.h" 13 : 14 :vPoint* vCurveCalculation::BattleField (vPoint* p1, vPoint* p2, vPoint* p3, vPoint* p4, float t) { 15 : vCalculation* calc = nullptr; 16 : 17 : printf("vCurveCalculation::BattleField: |%p|%p|%p|%p|", p1, p2, p3, p4 ); 18 : // calculation, revisement 19 : float tt = t*t; 20 : float c=2.0f; 21 : 22 : // Linear 23 : vPoint* p5 = calc->scalize( p1, (1.0f - t) ); // anchor p1 24 : vPoint* p6 = calc->scalize ( p4, t ); // anchor p4 25 : 26 : vPoint* point = calc->add ( p5, p6 ); 27 : 28 : //consider, p2 and p3 which are controls points. 29 : // Curve 30 : // if t=0: 31 : // curve_point=p1: 32 : // p2=0: 33 : // p3=0: 34 : // if t=1: 35 : // curve_point=p4: 36 : // p2=0: 37 : // p3=0: 38 : float graph = -0.5*( t - 0.5 )*( t - 0.5 ) + 1.0; 39 : vPoint* p7 = calc->scalize ( p2, graph ); 40 : vPoint* p8 = calc->scalize ( p3, graph ); 41 : vPoint* curve_point_001 = calc->add ( p7, p8 ); 42 : vPoint* curve_point = calc->scalize( curve_point_001, 0.5f); 43 : 44 : // Linear + Curve: Blend 45 : // Debug 46 : //vPoint* blend_001 = calc->add( curve_point, point ); 47 : vPoint* blend_001 = calc->add( curve_point, point ); 48 : vPoint* blend = calc->scalize( blend_001, 0.5f); 49 : 50 : level_error_msg = 2; 51 : // Calculated points printed. 52 : log_msg_003("p5="); 53 : p5->print(); 54 : log_msg_003("p7="); 55 : p7->print(); 56 : 57 : log_msg_003("curve_point="); 58 : curve_point->print(); 59 : log_msg_003("blend="); 60 : blend->print(); 61 : log_msg_003("blend_001="); 62 : blend_001->print(); 63 : log_msg_003("point="); 64 : point->print(); 65 : level_error_msg = 3; 66 : 67 : printf("vCurveCalculation::BattleField: |%p|\r\n", blend ); 68 :// exit(-1); 69 : return blend; 70 : 71 :// return curve_point; 72 :} 73 : 74 :// p1: Anchor 75 :// p2: setting controls 76 :// 77 :// p3: Anchor(next) 78 :// p4: setting controls 79 :// 80 :// vCurveCalculation 81 :// Position 82 :/* vPoint* vCurveCalculation::Position (vPoint* p1, vPoint* p2, vPoint p3, vPoint* p4, float t) { 83 : vCalculation* calc = nullptr; 84 : 85 : // calculation, revisement 86 : float tt = t*t; 87 : 88 : vPoint* p5 = calc->multiple ( p1, 1 - tt ); 89 : vPoint* p6 = calc->multiple ( p3, tt ); 90 : 91 : vPoint point calc->add ( p5, p6 ); 92 : 93 : //consider, p2 and p3 which is controls point. 94 : 95 : return point; 96 :}*/ 97 :