public Param.TypeParam ParamClassify(Param par) { par.Round(this.ParamStart, this.ParamEnd); double val = par.Val; if ((!par.IsValid) || (par.IsDegen)) { return(Param.TypeParam.Invalid); } if (val < 0) { return(Param.TypeParam.Before); } else if (val == 0) { return(Param.TypeParam.Start); } else if (val < 1) { return(Param.TypeParam.Inner); } else if (val == 1) { return(Param.TypeParam.End); } else { return(Param.TypeParam.After); } }
public Param.TypeParam ParamClassify(Param par) { par.Clip(-Param.Infinity, Param.Infinity); par.Round(0); double val = par.Val; if (val == Param.Degen) { return(Param.TypeParam.Invalid); } if (val == Param.Invalid) { return(Param.TypeParam.Invalid); } if (val < 0) { return(Param.TypeParam.Before); } else if (val == 0) { return(Param.TypeParam.Start); } else { return(Param.TypeParam.Inner); } }
public bool ParamFromSeg(Param par) { double valSeg = par.Val; if ((valSeg < 0) || (valSeg > 1)) { throw new ExceptionGMath("Bez2D", "ParamFromSeg", ""); //return false; } Param parM; if (!this.IsSeg(out parM)) { throw new ExceptionGMath("Bez2D", "ParamFromSeg", ""); //return false; } double valM = parM.Val; if (Math.Abs(valM - 0.5) < MConsts.EPS_DEC) { return(true); } double D = valM * valM + (1 - 2 * valM) * valSeg; if (Math.Abs(D) < MConsts.EPS_DEC) { D = 0; } if (D < 0) { throw new ExceptionGMath("Bez2D", "ParamFromSeg", ""); //return false; } double valBez = 0; if ((0.3 < valM) && (valM < 0.7)) // unstable for valM --> 0.5 { valBez = valSeg / (valM + Math.Sqrt(D)); } else { valBez = (-valM + Math.Sqrt(D)) / (1 - 2 * valM); } par.Val = valBez; par.Round(0, 1); if (!((par.Val >= 0.0) && (par.Val <= 1.0))) { throw new ExceptionGMath("Bez2D", "ParamFromSeg", ""); //return false; } return(true); }
public bool IsEvaluableStrict(Param par) { if (!par.IsValid) { return(false); } if (par.IsDegen) { return(this.IsDegen); } par.Round(this.ParamStart, this.ParamEnd); return((0 <= par) && (par <= 1)); }
public bool IsEvaluableStrict(Param par) { if ((par.IsDegen) || (!par.IsValid)) { return(false); } par.Round(this.ParamStart, this.ParamEnd); if (par.Val < 0) { return(false); } return(true); }
public bool IsEvaluableStrict(Param par) { if ((par.IsDegen)||(!par.IsValid)) return false; par.Round(this.ParamStart,this.ParamEnd); if (par.Val<0) return false; return true; }
public Param.TypeParam ParamClassify(Param par) { par.Clip(-Param.Infinity,Param.Infinity); par.Round(0); double val=par.Val; if (val==Param.Degen) return Param.TypeParam.Invalid; if (val==Param.Invalid) return Param.TypeParam.Invalid; if (val<0) { return Param.TypeParam.Before; } else if (val==0) { return Param.TypeParam.Start; } else { return Param.TypeParam.Inner; } }
public bool ParamFromSupport(Param parSupport, out Param[] parsBez) { parsBez = null; parSupport.Round(0, 1); if ((parSupport.Val < 0) || (parSupport.Val > 1)) { throw new ExceptionGMath("Bez2D", "ParamFromSupport", "Outside [0,1]"); //return false; } Param parM; if (!this.IsSelfInters(out parM)) { parsBez = new Param[1]; parsBez[0] = parSupport.Copy(); this.ParamFromSeg(parsBez[0]); return(true); } // self-intersecting Bezier double valM = parM.Val; if (valM == Param.Infinity) { double tau = 0.5 * parSupport.Val; // parameter with respect to [Cp(0),Cp(1)] parsBez = new Param[2]; parsBez[0] = new Param(0.5 * (1 - Math.Sqrt(1 - 2 * tau))); parsBez[1] = new Param(0.5 * (1 + Math.Sqrt(1 - 2 * tau))); return(true); } else if (valM > 1) { double tau = ((valM * valM) / (1 - 2 * valM)) * parSupport.Val; double D = valM * valM + tau * (1 - 2 * valM); if (Math.Abs(D) < MConsts.EPS_DEC) { D = 0; } if (D < 0) { throw new ExceptionGMath("BezD", "ParamFromSegGeneral", null); //return false; } if (tau < 1) { parsBez = new Param[1]; parsBez[0] = new Param((valM - Math.Sqrt(D)) / (1 - 2 * valM)); } else // 1<=tau<=(valM*valM)/(1-2*valM) { parsBez = new Param[2]; parsBez[0] = new Param((valM - Math.Sqrt(D)) / (1 - 2 * valM)); parsBez[1] = new Param((valM + Math.Sqrt(D)) / (1 - 2 * valM)); } return(true); } else { // valM<=1 Bez2D bezRev = this.Reversed as Bez2D; if (!bezRev.ParamFromSupport(1 - parSupport.Val, out parsBez)) { return(false); } if (parsBez == null) { return(true); } for (int iParBez = 0; iParBez < parsBez.Length; iParBez++) { parsBez[iParBez].Reverse(1); } return(true); } throw new ExceptionGMath("Bez2D", "ParamFromSupport", "NOT IMPLEMENTED"); //return false; }
public bool IsEvaluableStrict(Param par) { par.Round(this.ParamStart, this.ParamEnd); return((0 <= par) && (par <= 1)); }
public bool ParamFromSeg(Param par) { double valSeg=par.Val; if ((valSeg<0)||(valSeg>1)) { throw new ExceptionGMath("Bez2D","ParamFromSeg",""); //return false; } Param parM; if (!this.IsSeg(out parM)) { throw new ExceptionGMath("Bez2D","ParamFromSeg",""); //return false; } double valM=parM.Val; if (Math.Abs(valM-0.5)<MConsts.EPS_DEC) return true; double D = valM*valM+(1-2*valM)*valSeg; if (Math.Abs(D)<MConsts.EPS_DEC) { D=0; } if (D<0) { throw new ExceptionGMath("Bez2D","ParamFromSeg",""); //return false; } double valBez=0; if ((0.3<valM)&&(valM<0.7)) // unstable for valM --> 0.5 { valBez = valSeg/(valM+Math.Sqrt(D)); } else { valBez = (-valM+Math.Sqrt(D))/(1-2*valM); } par.Val=valBez; par.Round(0,1); if (!((par.Val>=0.0)&&(par.Val<=1.0))) { throw new ExceptionGMath("Bez2D","ParamFromSeg",""); //return false; } return true; }
public bool ParamFromSupport(Param parSupport, out Param[] parsBez) { parsBez=null; parSupport.Round(0,1); if ((parSupport.Val<0)||(parSupport.Val>1)) { throw new ExceptionGMath("Bez2D","ParamFromSupport",null); //return false; } Param parM; if (!this.IsSelfInters(out parM)) { parsBez=new Param[1]; parsBez[0]=parSupport.Copy(); this.ParamFromSeg(parsBez[0]); } // self-intersecting Bezier double valM=parM.Val; if (valM==Param.Infinity) { double tau=0.5*parSupport.Val; // parameter with respect to [Cp(0),Cp(1)] parsBez=new Param[2]; parsBez[0]=new Param(0.5*(1-Math.Sqrt(1-2*tau))); parsBez[1]=new Param(0.5*(1+Math.Sqrt(1-2*tau))); } else if (valM>1) { double tau=((valM*valM)/(1-2*valM))*parSupport.Val; double D=valM*valM+tau*(1-2*valM); if (Math.Abs(D)<MConsts.EPS_DEC) { D=0; } if (D<0) { throw new ExceptionGMath("BezD","ParamFromSegGeneral",null); //return false; } if (tau<1) { parsBez=new Param[1]; parsBez[0]=new Param((valM-Math.Sqrt(D))/(1-2*valM)); } else // 1<=tau<=(valM*valM)/(1-2*valM) { parsBez=new Param[2]; parsBez[0]=new Param((valM-Math.Sqrt(D))/(1-2*valM)); parsBez[1]=new Param((valM+Math.Sqrt(D))/(1-2*valM)); } return true; } else { // valM<0 Bez2D bezRev=this.Reversed as Bez2D; if (!bezRev.ParamFromSupport(1-parSupport.Val, out parsBez)) return false; if (parsBez==null) return true; for (int iParBez=0; iParBez<parsBez.Length; iParBez++) { parsBez[iParBez].Reverse(1); } return true; } throw new ExceptionGMath("Bez2D","ParamFromSupport","NOT IMPLEMENTED"); //return false; }
public Param.TypeParam ParamClassify(Param par) { par.Round(this.ParamStart,this.ParamEnd); double val=par.Val; if ((!par.IsValid)||(par.IsDegen)) { return Param.TypeParam.Invalid; } if (val<0) { return Param.TypeParam.Before; } else if (val==0) { return Param.TypeParam.Start; } else if (val<1) { return Param.TypeParam.Inner; } else if (val==1) { return Param.TypeParam.End; } else { return Param.TypeParam.After; } }
public bool IsEvaluableStrict(Param par) { par.Round(this.ParamStart,this.ParamEnd); return ((0<=par)&&(par<=1)); }
public bool IsEvaluableStrict(Param par) { if (!par.IsValid) return false; if (par.IsDegen) { return (this.IsDegen); } par.Round(this.ParamStart,this.ParamEnd); return ((0<=par)&&(par<=1)); }