mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
fix Intersect(BezierCurve, Line) and add tests
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UglyToad.PdfPig.Core;
|
||||
using UglyToad.PdfPig.Geometry;
|
||||
using Xunit;
|
||||
using static UglyToad.PdfPig.Core.PdfPath;
|
||||
|
||||
namespace UglyToad.PdfPig.Tests.Geometry
|
||||
namespace UglyToad.PdfPig.Tests.Geometry
|
||||
{
|
||||
using UglyToad.PdfPig.Core;
|
||||
using UglyToad.PdfPig.Geometry;
|
||||
using Xunit;
|
||||
using static UglyToad.PdfPig.Core.PdfPath;
|
||||
|
||||
public class BezierCurveTests
|
||||
{
|
||||
private static readonly DoubleComparer DoubleComparer = new DoubleComparer(3);
|
||||
@@ -22,59 +19,449 @@ namespace UglyToad.PdfPig.Tests.Geometry
|
||||
[Fact]
|
||||
public static void IntersectLine()
|
||||
{
|
||||
/**************************************************
|
||||
* WARNING: need to fix commented checks
|
||||
**************************************************/
|
||||
BezierCurve bezierCurve0 = new BezierCurve(new PdfPoint(264.24406059337, 813.2539040871427), new PdfPoint(696.8898111759918, 56.99330402388103), new PdfPoint(530.3310588633598, 506.5151019939086), new PdfPoint(865.7195297100383, 148.54460693931694));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(848.5833476027645, 249.7972802952747, 645.9117015843683, 998.2468623683882)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(607.5595639281848, 116.27633992951436, 95.80671059298784, 938.882966305257)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(123.74628642261443, 877.8068487303506, 152.99592406727146, 602.7622505939119)));
|
||||
var intersection00 = bezierCurve0.Intersect(new PdfLine(598.2439100496204, 645.812269413975, 376.05979531055533, 334.26190927095666));
|
||||
Assert.Single(intersection00);
|
||||
Assert.Contains(new PdfPoint(472.9200141187229, 470.08096226066334), intersection00, PointComparer);
|
||||
var intersection01 = bezierCurve0.Intersect(new PdfLine(546.2439963451685, 243.00088944385533, 884.7586448365444, 277.9886760412553));
|
||||
Assert.Single(intersection01);
|
||||
Assert.Contains(new PdfPoint(743.0947597105328, 263.3467519666647), intersection01, PointComparer);
|
||||
var intersection02 = bezierCurve0.Intersect(new PdfLine(232.2368180938804, 431.50902791570377, 534.8959037856006, 897.1174584572082));
|
||||
Assert.Single(intersection02);
|
||||
Assert.Contains(new PdfPoint(366.55331897442215, 638.1405091014888), intersection02, PointComparer);
|
||||
var intersection03 = bezierCurve0.Intersect(new PdfLine(31.97991174730963, 346.72297524548924, 855.6556915784224, 610.0572373336203));
|
||||
Assert.Single(intersection03);
|
||||
Assert.Contains(new PdfPoint(463.10166357218156, 484.5552767005874), intersection03, PointComparer);
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(228.3615143376261, 691.7415087698719, 433.3523064768595, 340.2084860006805)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(457.9903279142595, 558.7857524829263, 410.9942532245966, 702.6671134703336)));
|
||||
var intersection04 = bezierCurve0.Intersect(new PdfLine(206.92779499379165, 765.3797379190408, 890.4465440127814, 75.65722828804044));
|
||||
Assert.Equal(2, intersection04.Length);
|
||||
Assert.Contains(new PdfPoint(656.018795712754, 312.21269237253364), intersection04, PointComparer);
|
||||
Assert.Contains(new PdfPoint(421.1338954186477, 549.2294576592124), intersection04, PointComparer);
|
||||
var intersection05 = bezierCurve0.Intersect(new PdfLine(254.16517386300407, 349.0863817137981, 853.4926297593705, 662.3399204404022));
|
||||
Assert.Single(intersection05);
|
||||
Assert.Contains(new PdfPoint(476.2886889931002, 465.18481248705257), intersection05, PointComparer);
|
||||
var intersection06 = bezierCurve0.Intersect(new PdfLine(765.4460159119385, 387.1227206963288, 17.22429876512699, 607.1633951703885));
|
||||
Assert.Single(intersection06);
|
||||
Assert.Contains(new PdfPoint(470.2946331765248, 473.92227200674404), intersection06, PointComparer);
|
||||
var intersection07 = bezierCurve0.Intersect(new PdfLine(732.3194057273088, 966.1237930883087, 692.8623004412079, 97.83098807945333));
|
||||
Assert.Single(intersection07);
|
||||
Assert.Contains(new PdfPoint(701.652356789453, 291.264911512558), intersection07, PointComparer);
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(778.6022857517438, 187.81002970483763, 250.89610326365653, 375.2445758823829)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(153.0394273003609, 992.2698370612794, 162.43034542066093, 949.5573124999634)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(500.02698635044504, 130.1880787229075, 696.7479529045737, 127.34819316486067)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(662.6952283904454, 975.2134996992804, 646.8107117959146, 484.72387600958365)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(457.29180958103785, 458.8649891940185, 55.039192505030535, 656.5654294916582)));
|
||||
var intersection08 = bezierCurve0.Intersect(new PdfLine(716.4549088875565, 790.3154874963802, 45.64792111786009, 235.17079817249754));
|
||||
Assert.Single(intersection08);
|
||||
Assert.Contains(new PdfPoint(422.50806892160875, 547.0517318620134), intersection08, PointComparer);
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(195.81949402276376, 875.4297219300674, 805.1873113455099, 655.186957774872)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(413.1984379005661, 811.2772225482108, 409.51244066359925, 722.0924892124202)));
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(609.3551019101565, 304.2647028673933, 159.72329728989942, 34.54094363402926)));
|
||||
var intersection09 = bezierCurve0.Intersect(new PdfLine(558.2497527774033, 869.187467920054, 712.8744937998409, 11.05798605527497));
|
||||
Assert.Single(intersection09);
|
||||
Assert.Contains(new PdfPoint(658.7866503408275, 311.2322840088689), intersection09, PointComparer);
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(886.4067799003293, 511.9136438906965, 554.3115983879078, 931.1911113668294)));
|
||||
var intersection010 = bezierCurve0.Intersect(new PdfLine(785.3595499005729, 479.7025371527942, 611.2141100772869, 179.4338214753334));
|
||||
Assert.Single(intersection010);
|
||||
Assert.Contains(new PdfPoint(682.0537018977375, 301.5783535206564), intersection010, PointComparer);
|
||||
var intersection011 = bezierCurve0.Intersect(new PdfLine(321.621084439309, 475.36389926678413, 633.1760343300928, 348.4530248685414));
|
||||
Assert.Single(intersection011);
|
||||
Assert.Contains(new PdfPoint(534.025912772773, 388.8414976819008), intersection011, PointComparer);
|
||||
Assert.Empty(bezierCurve0.Intersect(new PdfLine(515.2846293146705, 726.8838424206828, 599.405992787059, 864.1087316340212)));
|
||||
var intersection012 = bezierCurve0.Intersect(new PdfLine(353.9362815893887, 672.5917806243287, 50.925604039722906, 758.8426113137531));
|
||||
Assert.Single(intersection012);
|
||||
Assert.Contains(new PdfPoint(344.3977858035639, 675.3068769757442), intersection012, PointComparer);
|
||||
var intersection013 = bezierCurve0.Intersect(new PdfLine(151.1779147895217, 943.951817899327, 763.9181431130075, 131.93947326413902));
|
||||
Assert.Equal(2, intersection013.Length);
|
||||
Assert.Contains(new PdfPoint(618.7960577395766, 324.2573909645181), intersection013, PointComparer);
|
||||
Assert.Contains(new PdfPoint(311.13271985276896, 731.9773623450541), intersection013, PointComparer);
|
||||
var intersection014 = bezierCurve0.Intersect(new PdfLine(490.826840906342, 230.73115479556805, 938.2499784455795, 275.1513105811465));
|
||||
Assert.Single(intersection014);
|
||||
Assert.Contains(new PdfPoint(751.7309524229952, 256.63370722593123), intersection014, PointComparer);
|
||||
|
||||
BezierCurve bezierCurve4 = new BezierCurve(new PdfPoint(838.9977979318809, 95.671193235772), new PdfPoint(395.7034695493279, 147.3440136838414), new PdfPoint(275.0076248732246, 55.57600730645929), new PdfPoint(957.0714444435359, 489.38731097550294));
|
||||
Assert.Null(bezierCurve4.Intersect(new PdfLine(405.7081633435599, 275.8998117922303, 421.00503949913616, 818.5738856248036)));
|
||||
//Assert.Null(bezierCurve4.Intersect(new PdfLine(619.6238321741257, 498.911907946902, 783.1759979436561, 402.350366461589)));
|
||||
var intersection40 = bezierCurve4.Intersect(new PdfLine(811.0936318489453, 676.5356886755211, 774.5959976348438, 102.96093324952781));
|
||||
Assert.Equal(2, intersection40.Length);
|
||||
Assert.Contains(new PdfPoint(792.5322042541575, 384.83551351939366), intersection40, PointComparer);
|
||||
//Assert.Null(bezierCurve4.Intersect(new PdfLine(856.1474641701632, 743.2580461805339, 720.8662662616595, 410.99413446464274)));
|
||||
var intersection41 = bezierCurve4.Intersect(new PdfLine(823.8777951547044, 36.37893536078452, 391.2772169996215, 486.92603750085107));
|
||||
Assert.Equal(2, intersection41.Length);
|
||||
Assert.Contains(new PdfPoint(759.0373802670636, 103.90926819985287), intersection41, PointComparer);
|
||||
Assert.Contains(new PdfPoint(605.601651552348, 263.7103096870932), intersection41, PointComparer);
|
||||
Assert.Null(bezierCurve4.Intersect(new PdfLine(967.0466595737648, 752.2192070165648, 596.5753647734898, 692.7867576537766)));
|
||||
Assert.Null(bezierCurve4.Intersect(new PdfLine(90.34993765825116, 172.47123605680758, 76.04014183010798, 962.5061481219865)));
|
||||
Assert.Null(bezierCurve4.Intersect(new PdfLine(253.4349734143222, 960.0704523419075, 132.1427266993902, 445.71575980737555)));
|
||||
var intersection42 = bezierCurve4.Intersect(new PdfLine(579.5358092911656, 37.6583106222359, 722.8194514003167, 857.3034484990549));
|
||||
Assert.Equal(2, intersection42.Length);
|
||||
Assert.Contains(new PdfPoint(593.3107646145511, 116.45708338571966), intersection42, PointComparer);
|
||||
Assert.Contains(new PdfPoint(620.8362608321851, 273.91496769357286), intersection42, PointComparer);
|
||||
Assert.Null(bezierCurve4.Intersect(new PdfLine(737.9400377401382, 699.699900336188, 49.684585625688335, 441.15809056920654)));
|
||||
Assert.Null(bezierCurve4.Intersect(new PdfLine(173.3662389987205, 783.1311908140424, 615.2539944045337, 790.1019706842866)));
|
||||
Assert.Null(bezierCurve4.Intersect(new PdfLine(296.94025013379644, 73.59632463536614, 42.0769232546675, 387.9093886277065)));
|
||||
var intersection43 = bezierCurve4.Intersect(new PdfLine(74.0977239040721, 619.3200447685273, 608.9545284349134, 100.34604393376978));
|
||||
Assert.Equal(2, intersection43.Length);
|
||||
Assert.Contains(new PdfPoint(592.2674109899074, 116.53763022279675), intersection43, PointComparer);
|
||||
Assert.Contains(new PdfPoint(511.3671755763147, 195.0354982229876), intersection43, PointComparer);
|
||||
var intersection44 = bezierCurve4.Intersect(new PdfLine(820.2163923944734, 717.173364146329, 953.5257410985023, 427.48244361487843));
|
||||
//Assert.Equal(2, intersection44.Length);
|
||||
Assert.Contains(new PdfPoint(932.2891103920052, 473.6311883065225), intersection44, PointComparer);
|
||||
var intersection45 = bezierCurve4.Intersect(new PdfLine(981.6646618092392, 105.86073123564721, 311.7334388081725, 996.5229973668335));
|
||||
//Assert.Equal(2, intersection45.Length);
|
||||
Assert.Contains(new PdfPoint(778.5328059619519, 375.92110883964796), intersection45, PointComparer);
|
||||
Assert.Null(bezierCurve4.Intersect(new PdfLine(123.98284286148686, 691.6900651406168, 49.549147941199024, 884.1694445599976)));
|
||||
var intersection46 = bezierCurve4.Intersect(new PdfLine(805.4005941396833, 728.6098454141719, 665.5457765690878, 34.05657022823405));
|
||||
Assert.Equal(2, intersection46.Length);
|
||||
Assert.Contains(new PdfPoint(680.8807262610109, 110.21368600267137), intersection46, PointComparer);
|
||||
Assert.Contains(new PdfPoint(727.8660773480029, 343.5544464434673), intersection46, PointComparer);
|
||||
var intersection47 = bezierCurve4.Intersect(new PdfLine(971.6420598824315, 380.15558036002307, 119.62220192520923, 98.55075618282515));
|
||||
//Assert.Equal(2, intersection47.Length);
|
||||
Assert.Contains(new PdfPoint(592.5403745718742, 254.85701784398492), intersection47, PointComparer);
|
||||
//Assert.Null(bezierCurve4.Intersect(new PdfLine(655.3922871321146, 433.7908714978125, 146.52092563817533, 408.2134759325372)));
|
||||
var intersection48 = bezierCurve4.Intersect(new PdfLine(567.711506436318, 464.54448311094296, 665.8463685771701, 182.0483112809783));
|
||||
Assert.Equal(2, intersection48.Length);
|
||||
Assert.Contains(new PdfPoint(631.4789419878045, 280.98019170903984), intersection48, PointComparer);
|
||||
BezierCurve bezierCurve1 = new BezierCurve(new PdfPoint(942.7792558619687, 935.3514215851535), new PdfPoint(258.75845448165626, 108.24117132318133), new PdfPoint(655.5842934652808, 156.9951446818767), new PdfPoint(399.51926584962104, 859.0442180524818));
|
||||
var intersection10 = bezierCurve1.Intersect(new PdfLine(773.2119256536688, 853.948207423979, 62.981204459828355, 177.97471535317365));
|
||||
Assert.Single(intersection10);
|
||||
Assert.Contains(new PdfPoint(479.2058611490295, 574.1232150903201), intersection10, PointComparer);
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(602.4414304434996, 46.85443585478954, 246.68193841356157, 138.64888646059325)));
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(437.278155002828, 470.7986973612184, 122.78886952453072, 828.7909248790899)));
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(13.069591858019148, 406.4884269415028, 551.5114319973826, 192.34952039801357)));
|
||||
var intersection11 = bezierCurve1.Intersect(new PdfLine(774.5721948308058, 39.65571238310262, 791.9923656588396, 883.5529224135099));
|
||||
Assert.Single(intersection11);
|
||||
Assert.Contains(new PdfPoint(789.0513025720555, 741.0769984996924), intersection11, PointComparer);
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(690.002790399079, 432.2724649098653, 605.4464113747196, 344.36403930852276)));
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(570.969364824303, 131.01500197097204, 105.77461957226663, 74.11672570210226)));
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(855.4856620572847, 16.786988938896407, 50.87764957525498, 678.4228744601722)));
|
||||
var intersection12 = bezierCurve1.Intersect(new PdfLine(406.4723228206391, 748.2240449902708, 665.6338871792933, 227.46228489534383));
|
||||
Assert.Equal(2, intersection12.Length);
|
||||
Assert.Contains(new PdfPoint(570.5054906533899, 418.61420718147514), intersection12, PointComparer);
|
||||
Assert.Contains(new PdfPoint(469.4903684054155, 621.5949732076417), intersection12, PointComparer);
|
||||
var intersection13 = bezierCurve1.Intersect(new PdfLine(558.0439318576009, 699.4372118160564, 675.0355116717019, 295.6056556940925));
|
||||
Assert.Single(intersection13);
|
||||
Assert.Contains(new PdfPoint(617.3288104424659, 494.7976573158951), intersection13, PointComparer);
|
||||
var intersection14 = bezierCurve1.Intersect(new PdfLine(516.0167618173216, 691.1508788415551, 548.5204371377848, 253.93736417937606));
|
||||
Assert.Single(intersection14);
|
||||
Assert.Contains(new PdfPoint(540.142134888394, 366.6356032936491), intersection14, PointComparer);
|
||||
var intersection15 = bezierCurve1.Intersect(new PdfLine(604.8242269510746, 542.197010104508, 782.411085075125, 259.9854290120964));
|
||||
Assert.Single(intersection15);
|
||||
Assert.Contains(new PdfPoint(626.0581827486279, 508.45313794090464), intersection15, PointComparer);
|
||||
var intersection16 = bezierCurve1.Intersect(new PdfLine(283.5190560852975, 754.198951114133, 930.010605581021, 113.14484191972429));
|
||||
Assert.Equal(2, intersection16.Length);
|
||||
Assert.Contains(new PdfPoint(589.7458416879076, 450.54774421270815), intersection16, PointComparer);
|
||||
Assert.Contains(new PdfPoint(482.31928279314377, 557.0707715745056), intersection16, PointComparer);
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(581.5442265850381, 52.745165519118785, 559.8806053478321, 292.1938780070465)));
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(909.7287815231144, 686.8830105446515, 711.9865217940237, 413.6092001616247)));
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(218.295468073465, 631.0331436358109, 401.16927189882546, 823.4379342080498)));
|
||||
var intersection17 = bezierCurve1.Intersect(new PdfLine(501.4691947048222, 629.10226035857, 22.241692623260366, 575.3227502455342));
|
||||
Assert.Single(intersection17);
|
||||
Assert.Contains(new PdfPoint(468.6420757831961, 625.4183599848243), intersection17, PointComparer);
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(128.55525098191723, 628.7107451041937, 385.1796101026809, 615.8332195293218)));
|
||||
var intersection18 = bezierCurve1.Intersect(new PdfLine(218.35740991576958, 589.4871625564143, 731.5808702127105, 302.7906504976773));
|
||||
Assert.Equal(2, intersection18.Length);
|
||||
Assert.Contains(new PdfPoint(559.0440479776568, 399.1730432820373), intersection18, PointComparer);
|
||||
Assert.Contains(new PdfPoint(498.6882169736456, 432.888973222662), intersection18, PointComparer);
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(162.56583266406633, 46.451616436717245, 44.027349747166376, 510.2684446415414)));
|
||||
var intersection19 = bezierCurve1.Intersect(new PdfLine(627.6758837892282, 864.5734286174757, 901.1135435889192, 187.57911576801467));
|
||||
Assert.Single(intersection19);
|
||||
Assert.Contains(new PdfPoint(717.1904347752529, 642.947621919139), intersection19, PointComparer);
|
||||
var intersection110 = bezierCurve1.Intersect(new PdfLine(337.170020583977, 255.48197144137663, 830.5455658855224, 667.63451778602));
|
||||
Assert.Equal(2, intersection110.Length);
|
||||
Assert.Contains(new PdfPoint(610.2503946707682, 483.60590787975246), intersection110, PointComparer);
|
||||
Assert.Contains(new PdfPoint(501.5980913707327, 392.84072120243064), intersection110, PointComparer);
|
||||
var intersection111 = bezierCurve1.Intersect(new PdfLine(910.1708675606546, 324.8419508838629, 310.2783343176444, 944.7009773696461));
|
||||
Assert.Equal(2, intersection111.Length);
|
||||
Assert.Contains(new PdfPoint(669.2147229399307, 573.8179473393242), intersection111, PointComparer);
|
||||
Assert.Contains(new PdfPoint(403.30644434521076, 848.576570876758), intersection111, PointComparer);
|
||||
var intersection112 = bezierCurve1.Intersect(new PdfLine(969.7518261185152, 456.4696630890725, 76.28719335760748, 584.6730296382586));
|
||||
Assert.Equal(2, intersection112.Length);
|
||||
Assert.Contains(new PdfPoint(624.4898169172294, 506.01135763199017), intersection112, PointComparer);
|
||||
Assert.Contains(new PdfPoint(487.5179816212091, 525.6654656553904), intersection112, PointComparer);
|
||||
var intersection113 = bezierCurve1.Intersect(new PdfLine(668.0996310115487, 824.6177106159012, 68.233938706316, 444.83515271334903));
|
||||
Assert.Single(intersection113);
|
||||
Assert.Contains(new PdfPoint(453.2497718543615, 688.5935470032891), intersection113, PointComparer);
|
||||
var intersection114 = bezierCurve1.Intersect(new PdfLine(189.628644451023, 664.4645532270152, 986.4962259850267, 770.1481088843353));
|
||||
Assert.Equal(2, intersection114.Length);
|
||||
Assert.Contains(new PdfPoint(791.4687233474999, 744.2828328870061), intersection114, PointComparer);
|
||||
Assert.Contains(new PdfPoint(450.4552796480081, 699.0563560014336), intersection114, PointComparer);
|
||||
var intersection115 = bezierCurve1.Intersect(new PdfLine(848.3046753268367, 584.8425978836959, 0.5472038867316842, 396.22478359621806));
|
||||
Assert.Equal(2, intersection115.Length);
|
||||
Assert.Contains(new PdfPoint(646.5825047354778, 539.961371598973), intersection115, PointComparer);
|
||||
Assert.Contains(new PdfPoint(490.51982408384185, 505.2389389363009), intersection115, PointComparer);
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(123.21146102014569, 5.509249990730658, 672.2979129870489, 138.69062931131114)));
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(308.7773257104942, 303.6348480728354, 259.5750242105016, 829.206079414991)));
|
||||
Assert.Empty(bezierCurve1.Intersect(new PdfLine(162.86888293939518, 118.14252634734667, 169.04128524438278, 794.0831918703078)));
|
||||
|
||||
BezierCurve bezierCurve2 = new BezierCurve(new PdfPoint(626.675834499726, 863.8237218759958), new PdfPoint(802.3642617154701, 380.07188952033135), new PdfPoint(445.36743321192506, 341.73864131554245), new PdfPoint(120.78231417941932, 714.0833782358343));
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(473.22019741443677, 724.5745443092098, 708.7581182332362, 972.5662776401396)));
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(965.1200240127546, 346.60862027477737, 520.6896866558712, 227.22570972634082)));
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(215.23140550995112, 949.1557726757148, 530.0488473270918, 953.9929239035425)));
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(114.396562230056, 593.6894484898892, 412.2411663541544, 216.26231641800743)));
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(138.47489948823744, 717.1747105598909, 534.1536222019888, 662.5414960923888)));
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(572.7434944017228, 27.919688921560603, 598.0026441864884, 80.43539491724283)));
|
||||
var intersection20 = bezierCurve2.Intersect(new PdfLine(581.7906658773471, 410.23729072196113, 126.4585310732601, 712.2630221498549));
|
||||
Assert.Single(intersection20);
|
||||
Assert.Contains(new PdfPoint(498.51650444763646, 465.4737600866248), intersection20, PointComparer);
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(167.39915268109706, 52.223574515543156, 968.3565311421593, 194.91259398472494)));
|
||||
var intersection21 = bezierCurve2.Intersect(new PdfLine(310.3281570936024, 545.6394426211873, 166.36180471723827, 588.7814709632493));
|
||||
Assert.Single(intersection21);
|
||||
Assert.Contains(new PdfPoint(303.9996363084492, 547.5358942473467), intersection21, PointComparer);
|
||||
var intersection22 = bezierCurve2.Intersect(new PdfLine(354.1653339283731, 225.53262201586233, 546.018154881293, 873.2472698395882));
|
||||
Assert.Single(intersection22);
|
||||
Assert.Contains(new PdfPoint(430.0411502392292, 481.69709953576375), intersection22, PointComparer);
|
||||
var intersection23 = bezierCurve2.Intersect(new PdfLine(893.3859460079068, 333.942983929868, 271.34802375346646, 831.1222863192686));
|
||||
Assert.Single(intersection23);
|
||||
Assert.Contains(new PdfPoint(647.5976231436388, 530.3954228008412), intersection23, PointComparer);
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(162.59634113921229, 227.72458469011713, 829.5792658545928, 264.6215778181266)));
|
||||
var intersection24 = bezierCurve2.Intersect(new PdfLine(41.04038301712454, 776.6920843275063, 679.18498552544, 501.4005036665062));
|
||||
Assert.Single(intersection24);
|
||||
Assert.Contains(new PdfPoint(639.8275217093334, 518.3790668043222), intersection24, PointComparer);
|
||||
var intersection25 = bezierCurve2.Intersect(new PdfLine(592.3564210480375, 809.7853797961488, 681.7115035764854, 161.11210824072165));
|
||||
Assert.Single(intersection25);
|
||||
Assert.Contains(new PdfPoint(633.5961519857284, 510.405530005278), intersection25, PointComparer);
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(908.9393831531471, 33.659903912675816, 883.5669369928378, 931.3628808019124)));
|
||||
var intersection26 = bezierCurve2.Intersect(new PdfLine(339.0366075630876, 894.9360145868387, 789.1961382100696, 169.56048513805456));
|
||||
Assert.Single(intersection26);
|
||||
Assert.Contains(new PdfPoint(596.2662637977414, 480.4427396961096), intersection26, PointComparer);
|
||||
var intersection27 = bezierCurve2.Intersect(new PdfLine(172.86042445169613, 587.4824736633736, 794.2309502713912, 631.6503751266416));
|
||||
Assert.Equal(2, intersection27.Length);
|
||||
Assert.Contains(new PdfPoint(672.4848088559017, 622.9964860956503), intersection27, PointComparer);
|
||||
Assert.Contains(new PdfPoint(244.37264970568967, 592.5656644282892), intersection27, PointComparer);
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(320.61298729187695, 361.0231925655503, 798.1617332444401, 85.22564000243915)));
|
||||
var intersection28 = bezierCurve2.Intersect(new PdfLine(16.80202386003571, 400.10974928064735, 776.9942589841537, 909.1343878276846));
|
||||
Assert.Equal(2, intersection28.Length);
|
||||
Assert.Contains(new PdfPoint(641.9393602813273, 818.7016422406573), intersection28, PointComparer);
|
||||
Assert.Contains(new PdfPoint(271.74887541891366, 570.8221335531262), intersection28, PointComparer);
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(450.07374177002913, 746.089214881157, 497.54379645359325, 700.4674308505631)));
|
||||
var intersection29 = bezierCurve2.Intersect(new PdfLine(377.031864193465, 934.03282399255, 187.6876187598988, 143.78183239657682));
|
||||
Assert.Single(intersection29);
|
||||
Assert.Contains(new PdfPoint(287.24952680162386, 559.3154356228013), intersection29, PointComparer);
|
||||
var intersection210 = bezierCurve2.Intersect(new PdfLine(377.859156329404, 14.52399517781011, 51.661375126104915, 952.3348136596571));
|
||||
Assert.Single(intersection210);
|
||||
Assert.Contains(new PdfPoint(143.25277559959756, 689.0117281160085), intersection210, PointComparer);
|
||||
var intersection211 = bezierCurve2.Intersect(new PdfLine(638.7394279957264, 926.1622261325971, 409.40547173339917, 251.01539126116813));
|
||||
Assert.Single(intersection211);
|
||||
Assert.Contains(new PdfPoint(483.00395357317336, 467.6853640611294), intersection211, PointComparer);
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(971.9172325201092, 807.2224571586986, 724.116724039428, 973.3590748815712)));
|
||||
var intersection212 = bezierCurve2.Intersect(new PdfLine(317.11425909498246, 871.8261265335558, 958.6715603989264, 324.7840337609617));
|
||||
Assert.Single(intersection212);
|
||||
Assert.Contains(new PdfPoint(665.2953033880693, 574.93964929027), intersection212, PointComparer);
|
||||
var intersection213 = bezierCurve2.Intersect(new PdfLine(347.17850345297586, 252.90462226515342, 446.2550920774778, 791.1549820929615));
|
||||
Assert.Single(intersection213);
|
||||
Assert.Contains(new PdfPoint(392.1207748054026, 497.0611284868504), intersection213, PointComparer);
|
||||
var intersection214 = bezierCurve2.Intersect(new PdfLine(230.12635046705842, 436.57039761755766, 626.8459657510524, 881.7878978285246));
|
||||
Assert.Single(intersection214);
|
||||
Assert.Contains(new PdfPoint(319.7119982726719, 537.1076451701986), intersection214, PointComparer);
|
||||
var intersection215 = bezierCurve2.Intersect(new PdfLine(189.09012124754378, 622.4278455654131, 842.5021915794358, 645.757137123151));
|
||||
Assert.Equal(2, intersection215.Length);
|
||||
Assert.Contains(new PdfPoint(673.0581835667989, 639.7073427512311), intersection215, PointComparer);
|
||||
Assert.Contains(new PdfPoint(209.24186244424476, 623.147339231233), intersection215, PointComparer);
|
||||
Assert.Empty(bezierCurve2.Intersect(new PdfLine(933.6803503287434, 977.3490198649527, 404.2478654015997, 946.6127175016314)));
|
||||
var intersection216 = bezierCurve2.Intersect(new PdfLine(51.58502831383949, 76.35165532369325, 993.3578703523407, 786.9882709721431));
|
||||
Assert.Equal(2, intersection216.Length);
|
||||
Assert.Contains(new PdfPoint(642.5323761030137, 522.2647295957565), intersection216, PointComparer);
|
||||
Assert.Contains(new PdfPoint(575.629346945794, 471.7814919245512), intersection216, PointComparer);
|
||||
|
||||
BezierCurve bezierCurve3 = new BezierCurve(new PdfPoint(486.37370359665357, 567.4134639356135), new PdfPoint(193.35004886979158, 148.0068280908642), new PdfPoint(275.09352619483207, 851.5063712011588), new PdfPoint(982.4414480073422, 21.379862326899037));
|
||||
var intersection30 = bezierCurve3.Intersect(new PdfLine(489.7495467958515, 680.4995476111018, 263.94078117488027, 162.8460681683045));
|
||||
Assert.Equal(2, intersection30.Length);
|
||||
Assert.Contains(new PdfPoint(391.170022465555, 454.511713918898), intersection30, PointComparer);
|
||||
Assert.Contains(new PdfPoint(390.38053096313797, 452.7018505059663), intersection30, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(969.6680664370842, 704.6792597665687, 808.4933577553227, 584.0996285558589)));
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(130.30491355956985, 946.7231116372456, 484.50192022356674, 921.6382341947924)));
|
||||
var intersection31 = bezierCurve3.Intersect(new PdfLine(895.5716624344604, 596.7078658509556, 360.4038641084467, 539.1482519446906));
|
||||
Assert.Single(intersection31);
|
||||
Assert.Contains(new PdfPoint(475.03263559058183, 551.4770726429831), intersection31, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(27.68444685471183, 326.0623317163699, 728.6752284411397, 63.26504014031453)));
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(538.3389805392408, 552.1395177105401, 916.7170755279442, 669.5104830657713)));
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(461.37024797082137, 839.8301137037548, 492.8616794960089, 603.5765418152405)));
|
||||
var intersection32 = bezierCurve3.Intersect(new PdfLine(268.42659387365154, 596.3971003626519, 748.0808002038013, 387.5082844616278));
|
||||
Assert.Single(intersection32);
|
||||
Assert.Contains(new PdfPoint(449.3132716479277, 517.6211750525531), intersection32, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(595.4092009270817, 382.27011792997246, 618.6782282568752, 612.274438821818)));
|
||||
var intersection33 = bezierCurve3.Intersect(new PdfLine(520.984912579851, 935.5581089181858, 569.8540546330574, 375.7742399456585));
|
||||
Assert.Single(intersection33);
|
||||
Assert.Contains(new PdfPoint(568.054594229106, 396.38661136585074), intersection33, PointComparer);
|
||||
var intersection34 = bezierCurve3.Intersect(new PdfLine(657.7488249734862, 852.3722823807329, 596.9814606690526, 118.36613303656995));
|
||||
Assert.Single(intersection34);
|
||||
Assert.Contains(new PdfPoint(617.4758689935693, 365.91713199058813), intersection34, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(986.0557151918596, 228.01173472537184, 612.1373542626386, 911.9214121334198)));
|
||||
var intersection35 = bezierCurve3.Intersect(new PdfLine(939.5128529938252, 896.5627318519623, 416.0624471338036, 44.615394096420346));
|
||||
Assert.Single(intersection35);
|
||||
Assert.Contains(new PdfPoint(614.633425952857, 367.80172630005563), intersection35, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(485.82851286602147, 802.0920736251709, 621.1620231966505, 996.1418000618473)));
|
||||
var intersection36 = bezierCurve3.Intersect(new PdfLine(752.6893097931531, 849.8664306681165, 288.9418644850095, 89.06811619629806));
|
||||
Assert.Single(intersection36);
|
||||
Assert.Contains(new PdfPoint(497.0942556225191, 430.5513738031839), intersection36, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(515.3658145401309, 468.27721448866765, 970.39846769459, 411.88077278543875)));
|
||||
var intersection37 = bezierCurve3.Intersect(new PdfLine(838.2268250236024, 210.0898546616331, 167.29812252075814, 814.5619739492755));
|
||||
Assert.Single(intersection37);
|
||||
Assert.Contains(new PdfPoint(468.77712885650004, 542.94495532914), intersection37, PointComparer);
|
||||
var intersection38 = bezierCurve3.Intersect(new PdfLine(936.7005387962886, 724.6749020274677, 262.7511202533006, 1.9003749156475402));
|
||||
Assert.Single(intersection38);
|
||||
Assert.Contains(new PdfPoint(607.9872025734367, 372.1475170236238), intersection38, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(989.7763283502331, 924.7570728417359, 433.5784642910531, 910.0404066408125)));
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(487.21681436987797, 184.21976557793795, 41.4954707453713, 433.78875529177617)));
|
||||
var intersection39 = bezierCurve3.Intersect(new PdfLine(716.3192340225694, 392.34500675943104, 289.3540869370893, 257.0287144899508));
|
||||
Assert.Single(intersection39);
|
||||
Assert.Contains(new PdfPoint(622.436631119758, 362.5911830102691), intersection39, PointComparer);
|
||||
var intersection310 = bezierCurve3.Intersect(new PdfLine(786.5959331460543, 197.8206942410833, 203.21662000665586, 846.138775586321));
|
||||
Assert.Equal(2, intersection310.Length);
|
||||
Assert.Contains(new PdfPoint(472.04779662669006, 547.3827026392552), intersection310, PointComparer);
|
||||
Assert.Contains(new PdfPoint(667.0952073150357, 330.62362287632743), intersection310, PointComparer);
|
||||
var intersection311 = bezierCurve3.Intersect(new PdfLine(507.5308346950791, 964.8013633865397, 373.51751972587175, 327.88333242330725));
|
||||
Assert.Equal(2, intersection311.Length);
|
||||
Assert.Contains(new PdfPoint(402.3714522635115, 465.0158994495175), intersection311, PointComparer);
|
||||
Assert.Contains(new PdfPoint(399.7806260796201, 452.70261616127664), intersection311, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(19.333100418875592, 959.7996361587946, 79.92925098535319, 395.5551372057625)));
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(961.9987174201857, 185.60322149019248, 435.36987754536926, 879.7686976831342)));
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(28.255551741759533, 572.6887166265348, 372.9051225936951, 646.2738362003748)));
|
||||
var intersection312 = bezierCurve3.Intersect(new PdfLine(323.0281571013513, 534.5966863622864, 990.722680332474, 571.5465987022325));
|
||||
Assert.Single(intersection312);
|
||||
Assert.Contains(new PdfPoint(468.5585990587694, 542.6502750709343), intersection312, PointComparer);
|
||||
var intersection313 = bezierCurve3.Intersect(new PdfLine(597.2757658642583, 303.24142198015034, 957.4609740706429, 978.1267540510505));
|
||||
Assert.Single(intersection313);
|
||||
Assert.Contains(new PdfPoint(627.216781267005, 359.3424268582971), intersection313, PointComparer);
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(255.98252602938499, 542.052338883152, 410.5074134174317, 29.075390947653325)));
|
||||
Assert.Empty(bezierCurve3.Intersect(new PdfLine(7.3204569983919, 674.8245694649106, 432.31411198758786, 950.5948472697074)));
|
||||
|
||||
BezierCurve bezierCurve4 = new BezierCurve(new PdfPoint(13.367959506581538, 973.9668880810086), new PdfPoint(375.89673216091126, 982.3978642120636), new PdfPoint(544.495373907041, 482.2063706500244), new PdfPoint(861.1023824894604, 99.07452151756857));
|
||||
var intersection40 = bezierCurve4.Intersect(new PdfLine(38.47382848554093, 769.9526352975384, 962.4490101042934, 404.8135213577777));
|
||||
Assert.Single(intersection40);
|
||||
Assert.Contains(new PdfPoint(529.7851506254286, 575.7948436126605), intersection40, PointComparer);
|
||||
var intersection41 = bezierCurve4.Intersect(new PdfLine(49.99292002312794, 834.0826194143368, 523.7916579171425, 671.3873595862808));
|
||||
Assert.Single(intersection41);
|
||||
Assert.Contains(new PdfPoint(442.56123996834174, 699.2806461173186), intersection41, PointComparer);
|
||||
Assert.Empty(bezierCurve4.Intersect(new PdfLine(246.52937895194415, 278.3039462592344, 287.5221739918284, 840.0173445801557)));
|
||||
var intersection42 = bezierCurve4.Intersect(new PdfLine(690.6867293924267, 644.8387482895614, 650.846432496891, 373.8971122624719));
|
||||
Assert.Single(intersection42);
|
||||
Assert.Contains(new PdfPoint(652.9371435298415, 388.11539655921854), intersection42, PointComparer);
|
||||
Assert.Empty(bezierCurve4.Intersect(new PdfLine(23.796762906157397, 300.2341209411864, 183.8501524784819, 585.370513157035)));
|
||||
var intersection43 = bezierCurve4.Intersect(new PdfLine(216.10985090779056, 233.52281320961742, 688.2963729155765, 636.9910856509139));
|
||||
Assert.Single(intersection43);
|
||||
Assert.Contains(new PdfPoint(561.2491556045818, 528.4333041433432), intersection43, PointComparer);
|
||||
var intersection44 = bezierCurve4.Intersect(new PdfLine(181.16278899497007, 767.4430264581257, 559.134437787313, 675.1758969191047));
|
||||
Assert.Single(intersection44);
|
||||
Assert.Contains(new PdfPoint(438.5128786171234, 704.6209758310126), intersection44, PointComparer);
|
||||
var intersection45 = bezierCurve4.Intersect(new PdfLine(416.14578935534075, 497.28310219112103, 856.4265340560795, 841.8598902977262));
|
||||
Assert.Single(intersection45);
|
||||
Assert.Contains(new PdfPoint(525.1891245730314, 582.6236551587119), intersection45, PointComparer);
|
||||
Assert.Empty(bezierCurve4.Intersect(new PdfLine(2.385414183783241, 161.0026091290765, 697.8971292612301, 177.80606622823592)));
|
||||
Assert.Empty(bezierCurve4.Intersect(new PdfLine(344.7232776250191, 662.8297054486951, 286.5540067188952, 868.7665239346061)));
|
||||
|
||||
BezierCurve bezierCurve5 = new BezierCurve(new PdfPoint(531.4218154552209, 541.9740951197103), new PdfPoint(976.5698212769013, 79.6449185775111), new PdfPoint(103.2227849405165, 789.1576335878276), new PdfPoint(164.2371395803388, 591.7728128683664));
|
||||
Assert.Empty(bezierCurve5.Intersect(new PdfLine(59.0718307944863, 894.2770724803187, 958.2054507562174, 841.3691684141248)));
|
||||
Assert.Empty(bezierCurve5.Intersect(new PdfLine(581.3023436022256, 601.1253406323195, 838.3275569046835, 159.6072509009837)));
|
||||
Assert.Empty(bezierCurve5.Intersect(new PdfLine(79.01454860161405, 946.3271000019588, 926.2191364490662, 675.0385396386184)));
|
||||
var intersection50 = bezierCurve5.Intersect(new PdfLine(98.2522338328119, 967.6778798830917, 764.4092378951432, 125.10880687794013));
|
||||
Assert.Single(intersection50);
|
||||
Assert.Contains(new PdfPoint(495.387761274695, 465.37270081330905), intersection50, PointComparer);
|
||||
var intersection51 = bezierCurve5.Intersect(new PdfLine(693.890997438059, 429.18290767845, 197.37692823730146, 597.9002384042851));
|
||||
Assert.Equal(2, intersection51.Length);
|
||||
Assert.Contains(new PdfPoint(378.6985934445324, 536.286460962345), intersection51, PointComparer);
|
||||
Assert.Contains(new PdfPoint(609.3550334509057, 457.90854322228586), intersection51, PointComparer);
|
||||
Assert.Empty(bezierCurve5.Intersect(new PdfLine(868.1837456549896, 324.42186197621834, 571.1705958838361, 304.02556247039934)));
|
||||
Assert.Empty(bezierCurve5.Intersect(new PdfLine(824.3867675544703, 264.993665040795, 265.5374807336691, 806.3325439334787)));
|
||||
var intersection52 = bezierCurve5.Intersect(new PdfLine(686.3572289843275, 912.6159124989666, 535.9365094055348, 238.3765366971048));
|
||||
Assert.Equal(2, intersection52.Length);
|
||||
Assert.Contains(new PdfPoint(575.8390599746992, 417.2340163315044), intersection52, PointComparer);
|
||||
Assert.Contains(new PdfPoint(589.8014224018209, 479.8183102635038), intersection52, PointComparer);
|
||||
var intersection53 = bezierCurve5.Intersect(new PdfLine(400.58787506524465, 208.89952438554204, 913.0129769610242, 707.6035108548583));
|
||||
Assert.Equal(2, intersection53.Length);
|
||||
Assert.Contains(new PdfPoint(600.5272076962639, 403.4851172189385), intersection53, PointComparer);
|
||||
Assert.Contains(new PdfPoint(630.5964951183095, 432.749244702521), intersection53, PointComparer);
|
||||
Assert.Empty(bezierCurve5.Intersect(new PdfLine(832.9477253198318, 433.76385853674424, 449.2831484582902, 193.64987940459534)));
|
||||
|
||||
BezierCurve bezierCurve6 = new BezierCurve(new PdfPoint(556.0924190504745, 688.5738034161749), new PdfPoint(727.9592440436122, 692.492390767496), new PdfPoint(960.8167189098734, 255.4002535005284), new PdfPoint(151.13793250340356, 423.29582734188574));
|
||||
var intersection60 = bezierCurve6.Intersect(new PdfLine(36.06499133480368, 77.98159064488175, 706.98281513665, 798.2737647180659));
|
||||
Assert.Equal(2, intersection60.Length);
|
||||
Assert.Contains(new PdfPoint(598.2068402626805, 681.4927214229008), intersection60, PointComparer);
|
||||
Assert.Contains(new PdfPoint(330.050922764211, 393.60260738322864), intersection60, PointComparer);
|
||||
Assert.Empty(bezierCurve6.Intersect(new PdfLine(946.5887621174827, 770.0003480767257, 725.2059781985627, 548.9496216236823)));
|
||||
var intersection61 = bezierCurve6.Intersect(new PdfLine(765.9223585845623, 238.80324032098198, 419.4564930787842, 436.4715099716122));
|
||||
Assert.Single(intersection61);
|
||||
Assert.Contains(new PdfPoint(507.9634407867678, 385.97587115895067), intersection61, PointComparer);
|
||||
var intersection62 = bezierCurve6.Intersect(new PdfLine(598.2562048972891, 797.7805360148245, 408.4633363418696, 13.610168343948569));
|
||||
Assert.Equal(2, intersection62.Length);
|
||||
Assert.Contains(new PdfPoint(571.6308116408148, 687.7719536153515), intersection62, PointComparer);
|
||||
Assert.Contains(new PdfPoint(498.47781384729353, 385.52448977441236), intersection62, PointComparer);
|
||||
var intersection63 = bezierCurve6.Intersect(new PdfLine(554.2529397184908, 245.09337721406342, 152.98917010750478, 988.6401389635729));
|
||||
Assert.Single(intersection63);
|
||||
Assert.Contains(new PdfPoint(478.76296406950615, 384.97724211611694), intersection63, PointComparer);
|
||||
var intersection64 = bezierCurve6.Intersect(new PdfLine(417.72307780050136, 58.75339216556819, 210.15283706589892, 598.1675806490321));
|
||||
Assert.Single(intersection64);
|
||||
Assert.Contains(new PdfPoint(286.69274194689956, 399.2628121626125), intersection64, PointComparer);
|
||||
Assert.Empty(bezierCurve6.Intersect(new PdfLine(808.7565374793816, 23.42644417329065, 400.5299874568554, 181.84997065501608)));
|
||||
Assert.Empty(bezierCurve6.Intersect(new PdfLine(626.0916405878419, 404.08328878944775, 48.428871462764974, 185.83208907005167)));
|
||||
Assert.Empty(bezierCurve6.Intersect(new PdfLine(564.8111345344545, 45.71210712361129, 924.3713710158369, 890.0004581237348)));
|
||||
Assert.Empty(bezierCurve6.Intersect(new PdfLine(529.373727052885, 74.44003713610337, 789.6050650932767, 293.6485504967945)));
|
||||
|
||||
BezierCurve bezierCurve7 = new BezierCurve(new PdfPoint(640.6746980578022, 829.94097824213), new PdfPoint(672.2612239744595, 145.95932024802704), new PdfPoint(336.1763046373777, 556.4608944044066), new PdfPoint(895.497609870072, 577.6830638766974));
|
||||
var intersection711 = bezierCurve7.Intersect(new PdfLine(935.6703298104218, 812.1920356490626, 148.5595881193914, 25.456041601060186));
|
||||
Assert.Equal(3, intersection711.Length);
|
||||
Assert.Contains(new PdfPoint(611.473974452321, 488.15003191343834), intersection711, PointComparer);
|
||||
Assert.Contains(new PdfPoint(569.0992168910718, 445.79544920139256), intersection711, PointComparer);
|
||||
Assert.Contains(new PdfPoint(649.8995053311473, 526.5572681910528), intersection711, PointComparer);
|
||||
|
||||
BezierCurve bezierCurve8 = new BezierCurve(new PdfPoint(123.74881096093272, 646.7730467003872), new PdfPoint(935.8592585589342, 76.23411374176715), new PdfPoint(84.25024277407766, 63.78670398075958), new PdfPoint(496.93407711755486, 495.95204094325373));
|
||||
var intersection81 = bezierCurve8.Intersect(new PdfLine(614.8215960172843, 46.52049376376366, 1.6586433696770264, 816.8461090609567));
|
||||
Assert.Equal(3, intersection81.Length);
|
||||
Assert.Contains(new PdfPoint(482.36295814622036, 212.93022429113486), intersection81, PointComparer);
|
||||
Assert.Contains(new PdfPoint(386.9828765553998, 332.7576204527738), intersection81, PointComparer);
|
||||
Assert.Contains(new PdfPoint(154.43215890808776, 624.9144996085561), intersection81, PointComparer);
|
||||
var intersection82 = bezierCurve8.Intersect(new PdfLine(298.62227171253187, 4.475176000749981, 637.8271063407608, 871.5117407020232));
|
||||
Assert.Equal(3, intersection82.Length);
|
||||
Assert.Contains(new PdfPoint(439.38881395610514, 364.2864957465665), intersection82, PointComparer);
|
||||
Assert.Contains(new PdfPoint(387.29296047885293, 231.1250392372474), intersection82, PointComparer);
|
||||
Assert.Contains(new PdfPoint(486.58369763579145, 484.9206543426831), intersection82, PointComparer);
|
||||
var intersection83 = bezierCurve8.Intersect(new PdfLine(686.2500121550859, 15.882945313319464, 136.38087749200756, 717.4771163030118));
|
||||
Assert.Equal(3, intersection83.Length);
|
||||
Assert.Contains(new PdfPoint(487.68712997998324, 269.2351557339404), intersection83, PointComparer);
|
||||
Assert.Contains(new PdfPoint(405.2436265538025, 374.4272419840964), intersection83, PointComparer);
|
||||
Assert.Contains(new PdfPoint(296.0125803262621, 513.7983404752039), intersection83, PointComparer);
|
||||
var intersection865 = bezierCurve8.Intersect(new PdfLine(490.48974648839874, 713.0722839226635, 460.93193273130896, 56.092196873792076));
|
||||
Assert.Equal(3, intersection865.Length);
|
||||
Assert.Contains(new PdfPoint(472.3853608449496, 310.6669858262673), intersection865, PointComparer);
|
||||
Assert.Contains(new PdfPoint(467.3419955851336, 198.568351785091), intersection865, PointComparer);
|
||||
Assert.Contains(new PdfPoint(479.89445158407005, 477.57118002641823), intersection865, PointComparer);
|
||||
var intersection897 = bezierCurve8.Intersect(new PdfLine(349.7131103051612, 150.87293817810854, 513.3310655874645, 960.5098722391302));
|
||||
Assert.Equal(3, intersection897.Length);
|
||||
Assert.Contains(new PdfPoint(402.1595579417103, 410.3956842824914), intersection897, PointComparer);
|
||||
Assert.Contains(new PdfPoint(377.32636559913084, 287.51265670459895), intersection897, PointComparer);
|
||||
Assert.Contains(new PdfPoint(385.65507317775314, 328.72591631911934), intersection897, PointComparer);
|
||||
var intersection8120 = bezierCurve8.Intersect(new PdfLine(341.9806797351892, 671.9586835569764, 399.43412914084433, 120.76308477732644));
|
||||
Assert.Equal(3, intersection8120.Length);
|
||||
Assert.Contains(new PdfPoint(388.08811491819915, 229.6142184848496), intersection8120, PointComparer);
|
||||
Assert.Contains(new PdfPoint(380.01572387602073, 307.05894043115325), intersection8120, PointComparer);
|
||||
Assert.Contains(new PdfPoint(365.14573574061575, 449.71829507268745), intersection8120, PointComparer);
|
||||
var intersection8137 = bezierCurve8.Intersect(new PdfLine(490.6172693862466, 84.54169417513768, 162.22419202633543, 841.082855390106));
|
||||
Assert.Equal(3, intersection8137.Length);
|
||||
Assert.Contains(new PdfPoint(443.59978564772354, 192.85902543837722), intersection8137, PointComparer);
|
||||
Assert.Contains(new PdfPoint(385.2210959711207, 327.3499289410128), intersection8137, PointComparer);
|
||||
Assert.Contains(new PdfPoint(309.35815323848794, 502.12047906813615), intersection8137, PointComparer);
|
||||
var intersection8143 = bezierCurve8.Intersect(new PdfLine(345.2722696152591, 15.814588535345342, 434.4672288428627, 515.6324048250635));
|
||||
Assert.Equal(3, intersection8143.Length);
|
||||
Assert.Contains(new PdfPoint(413.3687343723724, 397.40371203165375), intersection8143, PointComparer);
|
||||
Assert.Contains(new PdfPoint(384.6891102582153, 236.69298105671493), intersection8143, PointComparer);
|
||||
Assert.Contains(new PdfPoint(411.18672070271555, 385.17645931550794), intersection8143, PointComparer);
|
||||
var intersection8154 = bezierCurve8.Intersect(new PdfLine(109.17522383923416, 681.2267425891597, 464.59222380958664, 129.68770602864555));
|
||||
Assert.Equal(3, intersection8154.Length);
|
||||
Assert.Contains(new PdfPoint(420.2886468511531, 198.4383627329599), intersection8154, PointComparer);
|
||||
Assert.Contains(new PdfPoint(377.6303819631537, 264.63581057488364), intersection8154, PointComparer);
|
||||
Assert.Contains(new PdfPoint(137.7608154299374, 636.8673854206397), intersection8154, PointComparer);
|
||||
var intersection8166 = bezierCurve8.Intersect(new PdfLine(407.0754932857952, 152.49735128606778, 480.5695665222735, 745.9067289993372));
|
||||
Assert.Equal(3, intersection8166.Length);
|
||||
Assert.Contains(new PdfPoint(434.17818269343064, 371.3311884581021), intersection8166, PointComparer);
|
||||
Assert.Contains(new PdfPoint(413.2409195928753, 202.27853263996099), intersection8166, PointComparer);
|
||||
Assert.Contains(new PdfPoint(441.5748901681254, 431.05403938191023), intersection8166, PointComparer);
|
||||
var intersection8168 = bezierCurve8.Intersect(new PdfLine(129.16730453761727, 733.3566032322057, 524.5585547206936, 104.06653292667612));
|
||||
Assert.Equal(3, intersection8168.Length);
|
||||
Assert.Contains(new PdfPoint(465.7245704468277, 197.7045233549231), intersection8168, PointComparer);
|
||||
Assert.Contains(new PdfPoint(384.90635128023695, 326.33180784278926), intersection8168, PointComparer);
|
||||
Assert.Contains(new PdfPoint(235.96681696847972, 563.3784546133511), intersection8168, PointComparer);
|
||||
var intersection8180 = bezierCurve8.Intersect(new PdfLine(554.8075125011818, 914.1135470417131, 343.73486639821436, 109.8946655086115));
|
||||
Assert.Equal(3, intersection8180.Length);
|
||||
Assert.Contains(new PdfPoint(417.79842639972946, 392.08809268401853), intersection8180, PointComparer);
|
||||
Assert.Contains(new PdfPoint(380.3669747148428, 249.46856919780262), intersection8180, PointComparer);
|
||||
Assert.Contains(new PdfPoint(419.6860137423647, 399.28008752331976), intersection8180, PointComparer);
|
||||
Assert.Empty(bezierCurve8.Intersect(new PdfLine(868.2293540800841, 817.2542575863429, 715.9476751874303, 723.6560870358608)));
|
||||
Assert.Empty(bezierCurve8.Intersect(new PdfLine(848.2582460271959, 244.5813564840431, 800.6656860411097, 936.6878680873612)));
|
||||
var intersection8181 = bezierCurve8.Intersect(new PdfLine(309.2287280625947, 505.51592695874905, 443.6794698677693, 135.21664434166448));
|
||||
Assert.Equal(3, intersection8181.Length);
|
||||
Assert.Contains(new PdfPoint(420.8121113229546, 198.19708127196208), intersection8181, PointComparer);
|
||||
Assert.Contains(new PdfPoint(380.47464991695114, 309.293032255124), intersection8181, PointComparer);
|
||||
Assert.Contains(new PdfPoint(310.9856936536847, 500.67695701906445), intersection8181, PointComparer);
|
||||
var intersection8190 = bezierCurve8.Intersect(new PdfLine(351.40597655140795, 838.8597224880483, 438.2180531516747, 160.5938308316597));
|
||||
Assert.Equal(3, intersection8190.Length);
|
||||
Assert.Contains(new PdfPoint(406.9460152671703, 404.9233929191151), intersection8190, PointComparer);
|
||||
Assert.Contains(new PdfPoint(433.951852589948, 193.92580999060146), intersection8190, PointComparer);
|
||||
Assert.Contains(new PdfPoint(409.78769505302665, 382.7212460607831), intersection8190, PointComparer);
|
||||
var intersection8191 = bezierCurve8.Intersect(new PdfLine(210.34442369779958, 267.2932416416043, 752.1897805618169, 984.8090634391475));
|
||||
Assert.Equal(1, intersection8191.Length);
|
||||
Assert.Contains(new PdfPoint(355.3963912365989, 459.3721814599841), intersection8191, PointComparer);
|
||||
var intersection8192 = bezierCurve8.Intersect(new PdfLine(181.23171499485358, 435.2247333899155, 941.9935668012635, 366.09073076592136));
|
||||
Assert.Equal(2, intersection8192.Length);
|
||||
Assert.Contains(new PdfPoint(397.55147231006526, 415.566741030886), intersection8192, PointComparer);
|
||||
Assert.Contains(new PdfPoint(428.5169040627418, 412.7527668089142), intersection8192, PointComparer);
|
||||
Assert.Empty(bezierCurve8.Intersect(new PdfLine(94.15645205177603, 710.6272185346843, 497.65546042677346, 807.6037323819434)));
|
||||
Assert.Empty(bezierCurve8.Intersect(new PdfLine(157.2750616163997, 417.3318971053004, 73.62778964582506, 744.4068990421484)));
|
||||
var intersection8193 = bezierCurve8.Intersect(new PdfLine(572.8145471114285, 844.2092946761609, 128.061722485741, 633.9730118367311));
|
||||
Assert.Equal(1, intersection8193.Length);
|
||||
Assert.Contains(new PdfPoint(136.33268573269157, 637.8827263393965), intersection8193, PointComparer);
|
||||
Assert.Empty(bezierCurve8.Intersect(new PdfLine(921.5189474635717, 7.174385001839645, 750.3436541156324, 708.6881218940806)));
|
||||
var intersection8194 = bezierCurve8.Intersect(new PdfLine(355.9386188686681, 217.05579635181826, 824.0913894514908, 747.1604562669668));
|
||||
Assert.Equal(2, intersection8194.Length);
|
||||
Assert.Contains(new PdfPoint(459.4314667369343, 334.24412539782065), intersection8194, PointComparer);
|
||||
Assert.Contains(new PdfPoint(381.378472166126, 245.8621724494139), intersection8194, PointComparer);
|
||||
var intersection8195 = bezierCurve8.Intersect(new PdfLine(982.9926922832973, 336.0294046875853, 173.68409749996428, 381.5037637339772));
|
||||
Assert.Equal(2, intersection8195.Length);
|
||||
Assert.Contains(new PdfPoint(437.64489679831945, 366.67203176073724), intersection8195, PointComparer);
|
||||
Assert.Contains(new PdfPoint(402.2532927052592, 368.66065578145003), intersection8195, PointComparer);
|
||||
Assert.Empty(bezierCurve8.Intersect(new PdfLine(215.7243893126156, 170.98261058939812, 82.23950334821318, 90.3908237786144)));
|
||||
|
||||
}
|
||||
|
||||
//public static void FindIntersectionT()
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@@ -485,7 +485,6 @@
|
||||
/// </summary>
|
||||
public static PdfPoint? Intersect(this PdfLine line, PdfLine other)
|
||||
{
|
||||
if (!line.IntersectsWith(other)) return null;
|
||||
return Intersect(line.Point1, line.Point2, other.Point1, other.Point2);
|
||||
}
|
||||
|
||||
@@ -494,7 +493,6 @@
|
||||
/// </summary>
|
||||
public static PdfPoint? Intersect(this PdfLine line, PdfPath.Line other)
|
||||
{
|
||||
if (!line.IntersectsWith(other)) return null;
|
||||
return Intersect(line.Point1, line.Point2, other.From, other.To);
|
||||
}
|
||||
|
||||
@@ -547,7 +545,6 @@
|
||||
/// </summary>
|
||||
public static PdfPoint? Intersect(this PdfPath.Line line, PdfPath.Line other)
|
||||
{
|
||||
if (!line.IntersectsWith(other)) return null;
|
||||
return Intersect(line.From, line.To, other.From, other.To);
|
||||
}
|
||||
|
||||
@@ -556,7 +553,6 @@
|
||||
/// </summary>
|
||||
public static PdfPoint? Intersect(this PdfPath.Line line, PdfLine other)
|
||||
{
|
||||
if (!line.IntersectsWith(other)) return null;
|
||||
return Intersect(line.From, line.To, other.Point1, other.Point2);
|
||||
}
|
||||
|
||||
@@ -604,7 +600,7 @@
|
||||
return tx >= 0 && (tx - 1) <= epsilon;
|
||||
}
|
||||
|
||||
public static bool IntersectsWith(PdfPoint p11, PdfPoint p12, PdfPoint p21, PdfPoint p22)//this PdfPath.Line line, PdfPath.Line other)
|
||||
public static bool IntersectsWith(PdfPoint p11, PdfPoint p12, PdfPoint p21, PdfPoint p22)
|
||||
{
|
||||
return (ccw(p11, p12, p21) != ccw(p11, p12, p22)) &&
|
||||
(ccw(p21, p22, p11) != ccw(p21, p22, p12));
|
||||
@@ -612,6 +608,8 @@
|
||||
|
||||
private static PdfPoint? Intersect(PdfPoint p11, PdfPoint p12, PdfPoint p21, PdfPoint p22)
|
||||
{
|
||||
if (!IntersectsWith(p11, p12, p21, p22)) return null;
|
||||
|
||||
var eq1 = GetSlopeIntercept(p11, p12);
|
||||
var eq2 = GetSlopeIntercept(p21, p22);
|
||||
|
||||
@@ -659,6 +657,7 @@
|
||||
bezierCurve.SecondControlPoint,
|
||||
bezierCurve.EndPoint
|
||||
};
|
||||
|
||||
points[1] = new PdfPoint[3];
|
||||
points[2] = new PdfPoint[2];
|
||||
points[3] = new PdfPoint[1];
|
||||
@@ -677,14 +676,49 @@
|
||||
new PdfPath.BezierCurve(points[3][0], points[2][1], points[1][2], points[0][3]));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the curve and the line are intersecting.
|
||||
/// <para>Avoid using this method as it is not optimised. Use <see cref="Intersect(PdfPath.BezierCurve, PdfLine)"/> instead.</para>
|
||||
/// </summary>
|
||||
public static bool IntersectsWith(this PdfPath.BezierCurve bezierCurve, PdfLine line)
|
||||
{
|
||||
return IntersectsWith(bezierCurve, line.Point1, line.Point2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the curve and the line are intersecting.
|
||||
/// <para>Avoid using this method as it is not optimised. Use <see cref="Intersect(PdfPath.BezierCurve, PdfPath.Line)"/> instead.</para>
|
||||
/// </summary>
|
||||
public static bool IntersectsWith(this PdfPath.BezierCurve bezierCurve, PdfPath.Line line)
|
||||
{
|
||||
return IntersectsWith(bezierCurve, line.From, line.To);
|
||||
}
|
||||
|
||||
private static bool IntersectsWith(PdfPath.BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
|
||||
{
|
||||
return Intersect(bezierCurve, p1, p2).Length > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="PdfPoint"/>s that are the intersections of the line and the curve.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static PdfPoint[] Intersect(this PdfPath.BezierCurve bezierCurve, PdfLine line)
|
||||
{
|
||||
var ts = FindIntersectionT(bezierCurve, line);
|
||||
if (ts == null || !ts.Any()) return null;
|
||||
return Intersect(bezierCurve, line.Point1, line.Point2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="PdfPoint"/>s that are the intersections of the line and the curve.
|
||||
/// </summary>
|
||||
public static PdfPoint[] Intersect(this PdfPath.BezierCurve bezierCurve, PdfPath.Line line)
|
||||
{
|
||||
return Intersect(bezierCurve, line.From, line.To);
|
||||
}
|
||||
|
||||
private static PdfPoint[] Intersect(PdfPath.BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
|
||||
{
|
||||
var ts = FindIntersectionT(bezierCurve, p1, p2);
|
||||
if (ts == null || !ts.Any()) return EmptyArray<PdfPoint>.Instance;
|
||||
|
||||
List<PdfPoint> points = new List<PdfPoint>();
|
||||
foreach (var t in ts)
|
||||
@@ -700,36 +734,7 @@
|
||||
bezierCurve.SecondControlPoint.Y,
|
||||
bezierCurve.EndPoint.Y,
|
||||
t));
|
||||
points.Add(point);
|
||||
}
|
||||
return points.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="PdfPoint"/>s that are the intersections of the line and the curve.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static PdfPoint[] Intersect(this PdfPath.BezierCurve bezierCurve, PdfPath.Line line)
|
||||
{
|
||||
var ts = FindIntersectionT(bezierCurve, line);
|
||||
if (ts == null || !ts.Any()) return null;
|
||||
|
||||
List<PdfPoint> points = new List<PdfPoint>();
|
||||
foreach (var t in ts)
|
||||
{
|
||||
PdfPoint point = new PdfPoint(
|
||||
PdfPath.BezierCurve.ValueWithT(bezierCurve.StartPoint.X,
|
||||
bezierCurve.FirstControlPoint.X,
|
||||
bezierCurve.SecondControlPoint.X,
|
||||
bezierCurve.EndPoint.X,
|
||||
t),
|
||||
PdfPath.BezierCurve.ValueWithT(bezierCurve.StartPoint.Y,
|
||||
bezierCurve.FirstControlPoint.Y,
|
||||
bezierCurve.SecondControlPoint.Y,
|
||||
bezierCurve.EndPoint.Y,
|
||||
t)
|
||||
);
|
||||
points.Add(point);
|
||||
if (Contains(p1, p2, point)) points.Add(point);
|
||||
}
|
||||
return points.ToArray();
|
||||
}
|
||||
@@ -740,21 +745,7 @@
|
||||
/// <returns>List of t values where the <see cref="PdfPath.BezierCurve"/> and the <see cref="PdfLine"/> intersect.</returns>
|
||||
public static double[] FindIntersectionT(this PdfPath.BezierCurve bezierCurve, PdfLine line)
|
||||
{
|
||||
// if the bounding boxes do not intersect, they cannot intersect
|
||||
var bezierBbox = bezierCurve.GetBoundingRectangle();
|
||||
if (!bezierBbox.HasValue) return null;
|
||||
var lineBbox = line.GetBoundingRectangle();
|
||||
|
||||
if (!bezierBbox.Value.IntersectsWith(lineBbox))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
double x1 = line.Point1.X;
|
||||
double y1 = line.Point1.Y;
|
||||
double x2 = line.Point2.X;
|
||||
double y2 = line.Point2.Y;
|
||||
return FindIntersectionT(bezierCurve, x1, y1, x2, y2);
|
||||
return FindIntersectionT(bezierCurve, line.Point1, line.Point2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -762,30 +753,29 @@
|
||||
/// </summary>
|
||||
/// <returns>List of t values where the <see cref="PdfPath.BezierCurve"/> and the <see cref="PdfPath.Line"/> intersect.</returns>
|
||||
public static double[] FindIntersectionT(this PdfPath.BezierCurve bezierCurve, PdfPath.Line line)
|
||||
{
|
||||
return FindIntersectionT(bezierCurve, line.From, line.To);
|
||||
}
|
||||
|
||||
private static double[] FindIntersectionT(PdfPath.BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
|
||||
{
|
||||
// if the bounding boxes do not intersect, they cannot intersect
|
||||
var bezierBbox = bezierCurve.GetBoundingRectangle();
|
||||
if (!bezierBbox.HasValue) return null;
|
||||
var lineBbox = line.GetBoundingRectangle();
|
||||
if (!lineBbox.HasValue) return null;
|
||||
|
||||
if (!bezierBbox.Value.IntersectsWith(lineBbox.Value))
|
||||
if (bezierBbox.Value.Left > Math.Max(p1.X, p2.X) || Math.Min(p1.X, p2.X) > bezierBbox.Value.Right)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
double x1 = line.From.X;
|
||||
double y1 = line.From.Y;
|
||||
double x2 = line.To.X;
|
||||
double y2 = line.To.Y;
|
||||
return FindIntersectionT(bezierCurve, x1, y1, x2, y2);
|
||||
if (bezierBbox.Value.Top < Math.Min(p1.Y, p2.Y) || Math.Max(p1.Y, p2.Y) < bezierBbox.Value.Bottom)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private static double[] FindIntersectionT(PdfPath.BezierCurve bezierCurve, double x1, double y1, double x2, double y2)
|
||||
{
|
||||
double A = (y2 - y1);
|
||||
double B = (x1 - x2);
|
||||
double C = x1 * (y1 - y2) + y1 * (x2 - x1);
|
||||
double A = (p2.Y - p1.Y);
|
||||
double B = (p1.X - p2.X);
|
||||
double C = p1.X * (p1.Y - p2.Y) + p1.Y * (p2.X - p1.X);
|
||||
|
||||
double alpha = bezierCurve.StartPoint.X * A + bezierCurve.StartPoint.Y * B;
|
||||
double beta = 3.0 * (bezierCurve.FirstControlPoint.X * A + bezierCurve.FirstControlPoint.Y * B);
|
||||
@@ -799,7 +789,7 @@
|
||||
|
||||
var solution = SolveCubicEquation(a, b, c, d);
|
||||
|
||||
return solution.Where(s => !double.IsNaN(s)).Where(s => s >= -epsilon && s <= 1.0).OrderBy(s => s).ToArray();
|
||||
return solution.Where(s => !double.IsNaN(s)).Where(s => s >= -epsilon && (s - 1) <= epsilon).OrderBy(s => s).ToArray();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -836,7 +826,7 @@
|
||||
/// <param name="d">d</param>
|
||||
private static double[] SolveCubicEquation(double a, double b, double c, double d)
|
||||
{
|
||||
if (Math.Abs(a) <= double.Epsilon)
|
||||
if (Math.Abs(a) <= epsilon)
|
||||
{
|
||||
// handle Quadratic equation (a=0)
|
||||
double detQ = c * c - 4 * b * d;
|
||||
@@ -846,7 +836,7 @@
|
||||
double x0 = (-c - Math.Sqrt(detQ)) / (2.0 * b);
|
||||
return new double[] { x, x0 };
|
||||
}
|
||||
return new double[0]; // no real roots
|
||||
return EmptyArray<double>.Instance; // no real roots
|
||||
}
|
||||
|
||||
double aSquared = a * a;
|
||||
@@ -875,7 +865,7 @@
|
||||
|
||||
// Complex roots
|
||||
double complexPart = Math.Sqrt(3) / 2.0 * (S - T); // complex part of complex root
|
||||
if (Math.Abs(complexPart) <= double.Epsilon) // if complex part == 0
|
||||
if (Math.Abs(complexPart) <= epsilon) // if complex part == 0
|
||||
{
|
||||
// complex roots only have real part
|
||||
// the real part is the same for both roots
|
||||
|
Reference in New Issue
Block a user