Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intersectn gives a different output to "a different function" #52

Closed
MLIrstea opened this issue Sep 17, 2020 · 2 comments
Closed

intersectn gives a different output to "a different function" #52

MLIrstea opened this issue Sep 17, 2020 · 2 comments

Comments

@MLIrstea
Copy link

Dear all,

I tried intersectn with two sets of point and get an intersected volume of 0, while with a different function I got a different estimation (about 388).
Here the two set of points.
setu <- structure(c(0.358272604860056, -1.20484799657496, 2.82200108251569, 1.28469950664444, 1.35919560909985, 0.0253534823757413, 0.444581979415118, 0.466238506171745, 0.578921679945911, 1.23158702433283, 3.15634835946662, 0.687781929513476, 0.286297204371058, 0.192376272936267, 0.38870349471695, -0.0486712943161579, 0.725602727788623, 0.402601938714911, 0.710524700738645, 0.22473515792423, 0.243238330802982, -0.186070433584766, -0.175403130605532, 0.267431126704434, -0.860543631112881, 2.25526259738952, 1.64080118846112, 0.854071398457527, 0.663908098851796, 0.895769674982329, 1.6621689515305, 0.909657466746676, 1.04504893841291, 1.49701976888627, 1.14703931945574, 0.858275628303836, 1.53264479202947, 1.37316976699112, 1.38678143508729, 0.864665001581989, 0.628506738354286, 1.6377583211111, 5.00494102318079, 6.72429949619011, -0.00122143167880179, 0.31246812890208, 1.16561128533832, -0.520240389471783, -0.555576701343734, -0.700602479928758, 0.257197029002669, 0.897944204557231, 0.293224046138846, 0.601042026387928, 2.37420983028853, 1.67705254567893, 1.57033997455353, -1.99818090611529, 2.13973937768414, 2.5753147449154, 0.571237333061748, 1.15509475470561, 0.407173570577252, 0.191779641826796, 0.0801970102564962, 0.687418781556543, -0.116963526081052, 1.23950443047354, 0.850104378747012, 0.790000458154444, 1.72427445715258, 0.952823124262757, 0.842684245697185, 0.763561271914263, -3.60017762497627, -5.19677966124592, 9.1934949678319, 2.01700064974679, 0.668562735895464, -1.10272870218522, -3.52432543945342, 0.921086450400769, 0.170621876598605, 0.392157463405524, 0.074154514727245, 2.11473786949572, -0.539726384059189, 0.940505986534183, 0.588204251361066, 0.167984770894866, 0.272075113173542, -1.52663312039498, -2.11488885721921, -0.533513779744364, 0.172345938616453, -2.29582679572681, -1.20243525528554, -0.589564984114742, -1.24626180287737, -0.678090344226059, -0.244019122087957, -0.395844800196698, -0.45871856380231, -1.12713298808856, 2.16049680054357, -0.193622318008471, 0.633741880579295, 0.781684873387375, -1.24032673859453, -0.3521020887046, -1.08108256010365, -0.662597021290916, 0.119665024075628, -0.46359965532882, 0.192106894099836, -0.306588216311278, -0.965881512655237, -1.12085374043153, -0.288906624176471, -0.694502525906697, -0.278436797717285, 2.99497065188104, 0.591778900785123, -0.399536132426651, 0.0876228130815711, -0.0557392226201585, -0.446098745000371, -0.633695223767932, -0.892672722275711, -0.736336493537762, -1.72275395105636, -1.28246072730312, -0.562522623331824, 0.629594432360898, -0.203616867138874, 0.0819699850465393, -0.481323490469697, 0.289399976624292, 0.0851396130379308, -1.70149897784672, -1.36481974253701, -2.13017896404893, -1.57192075047312, -1.40533764071299, -1.20466629067429, 0.665726789566798, 2.07077952406642, -1.53160552935134, 0.260140669203414, -0.354389579720782, -0.880136811861489, -1.73940938763137, -1.00995026849067, -0.18694335953871, -0.996276846480419, 4.66364376034552, -0.384266247406289, -0.51497261781287, 0.410446120585204, -8.05280794333236, 0.846418029251948, -0.473473669550119, -0.22009092358684, -1.14862983963887, -0.345477817683903, -1.10455386319915, 0.239987842283917, -2.26439807047638, -6.62386103393725, 0.737871909405577, 0.851645104827465, -0.797387379621025, -0.024300999166472, 2.02866605867842, -0.437656804001136, 0.479322129923222, 0.614231679252136, 0.14446329257022, 0.100843175865097, 1.18408218045723, 0.981757579814104, 1.38620494217336, -0.436004698474075, -1.3455960869297, -3.45770557465564, 1.90565720312055, 0.491503617013778, 0.656220197803928, 0.957069876517388, 0.580800449010137, 1.45570356016923, 1.16121884505529, 0.961186710816588, 0.486353117358673, 1.45531939121849, 1.29691945663991, 1.03701843140314, -1.47539080780684, 1.22875620644583, 0.125546070883124, -5.58912780569294, -4.74712871316743, 0.558068763333632, 0.49375232760385, 1.3392725471067, 1.31462186042328, 1.47134408703615, 0.898332018057788, 1.16865411023886, 1.00164756284456, 0.380691035423344, 1.06164689889648, 1.2433360788338, -0.170123699502472, -0.859916995583392, -0.933607480932669, -1.94397184170948, 0.371762021723303, -0.0822671636073955, 0.761772242130567, -0.0322412205584391, 0.0355700211561725, 0.123354416484441, 0.620127856146004, -0.252540914156587, 0.118699493378956, 0.411482696746033, 0.381882242925506, 1.17481786697446, 0.191986879132848, 0.281660161140424, 0.18228595706917, -0.857882890789265, -0.757881157750692, -5.64304520553749, -1.18990827347873, -0.492440972237434, 0.427344765192214, 8.83190026265947, 0.555374339856875, 0.99596112723802, 0.639314953308649, 1.68848366880681, 0.709549116220173, 0.794076148447284, 0.38797712579671, 1.69825357894899, 0.0641288315786146, 0.311418880881956, 0.503819292501282, -0.897559153773898, -0.603815253238222, 0.169905537296221, 1.36599488578331, 0.206187497307935, -0.893402278417459, -1.33175546247103, -0.661818165985605, 0.256822234185706, 0.408066754377194, 0.27335045020237, 0.398130288771763, -0.14492928433536, 1.03214292596749, 0.431623647383189, -0.839727448827881, -1.14236866347815, -1.08834807370416, -1.35121828422114, -0.891087470698212, -1.3906313963369, -1.22355289277524, -1.00582995607662, -0.699252162661518, -0.335989120441702, -1.08271057284286, 2.53685687474027, -0.181651930354155, -1.08316840066793, 2.89482579144518, 2.03172163795401, 0.990714210126454, 0.994755961929098, 1.09093308657261, 1.90929092408626, 0.735166914427706, 1.48190791868422, 0.528544691130735, -1.63981361113545, -1.07025614536494, -1.1024145716157, -0.925610911973686, 0.696749147278287, 2.40297589683478, 0.964172086790592, 4.42127189557637, 1.77707550244555, 0.247764057184193, -0.887966403690736, -1.28255283281329, -1.13142443218222, -0.849703986783566, -0.841274727256044, -0.245085657093046, 0.0243354384540441, -1.12096055262357, -0.164487484148602, -0.668521147250858, 1.39828689657999, -1.3438888908589, -0.919408185317513, 1.42425300355446, 3.09794697168367, 0.766481474313542, -0.590497791200817, -0.928262810898515), .Dim = c(79L, 4L), .Dimnames = list(NULL, c("PC1", "PC2", "PC3", "PC4"))) setv <- structure(c(-1.20484799657496, 1.28469950664444, 1.35919560909985, 0.877065597730123, 0.0253534823757413, 0.444581979415118, 0.466238506171745, 1.23158702433283, 0.266294029153322, 3.15634835946662, 0.687781929513476, 5.89345446938327, -1.42657403264951, 0.286297204371058, 0.38870349471695, -0.0486712943161579, 0.295143741496781, 0.725602727788623, 0.402601938714911, 0.710524700738645, 0.243238330802982, -0.175403130605532, -0.125202807660436, -0.860543631112881, -0.37678102139601, 2.25526259738952, 1.64080118846112, 0.172328967436481, 0.233319372628378, 0.854071398457527, 0.663908098851796, 1.20388652796361, 0.223129466714911, 0.895769674982329, 1.6621689515305, 1.04504893841291, 1.84242731878802, 1.34183572652178, 1.53264479202947, 1.37316976699112, 1.38678143508729, 0.471847456816037, 0.864665001581989, 1.6377583211111, 5.66371421738663, 5.00494102318079, 0.31246812890208, 1.16561128533832, -0.520240389471783, -0.555576701343734, -0.319554440278763, -0.700602479928758, 0.48701212934822, 0.257197029002669, 0.897944204557231, 0.601042026387928, 0.917327582222588, -0.937218784720318, 2.37420983028853, 1.53274358228525, 1.57033997455353, -1.99818090611529, 2.13973937768414, -1.66786907088901, 0.571237333061748, 1.15509475470561, 0.407173570577252, -0.697386482449181, 0.191779641826796, 0.0801970102564962, 0.687418781556543, -0.171858735939651, -0.116963526081052, 1.23950443047354, 0.850104378747012, 0.790000458154444, 1.72427445715258, 0.952823124262757, 0.842684245697185, 0.96648636430592, 0.338045590726199, -0.403345989179986, 0.615414781587213, 9.1934949678319, 2.01700064974679, -3.52432543945342, 0.170621876598605, 0.392157463405524, -0.458381329832434, 0.074154514727245, 2.11473786949572, -0.539726384059189, 0.588204251361066, 0.755320937839567, 0.167984770894866, 0.272075113173542, 0.448285536640726, -1.70573871119128, -1.52663312039498, -0.533513779744364, 0.172345938616453, -0.750043763527636, -2.29582679572681, -1.20243525528554, -0.589564984114742, -0.678090344226059, -0.395844800196698, -0.00247725228698793, -1.12713298808856, -0.939134255786291, 2.16049680054357, -0.193622318008471, 1.41822338386331, 0.357380410699066, 0.633741880579295, 0.781684873387375, 1.94835286550069, -0.539693976263741, -1.24032673859453, -0.3521020887046, -0.662597021290916, 0.0762612055045866, -0.660563922712825, -0.306588216311278, -0.965881512655237, -1.12085374043153, -0.926419396781102, -0.288906624176471, -0.278436797717285, -1.22039311472963, 2.99497065188104, 0.0876228130815711, -0.0557392226201585, -0.446098745000371, -0.633695223767932, 0.0470490530473751, -0.892672722275711, -0.460615220189869, -0.736336493537762, -1.72275395105636, -0.562522623331824, -0.460524118948032, -0.719458217628372, 0.629594432360898, 0.465287304040667, 0.0819699850465393, -0.481323490469697, 0.289399976624292, -0.35823367736356, -1.70149897784672, -1.36481974253701, -2.13017896404893, -0.666748714287258, -1.57192075047312, -1.40533764071299, -1.20466629067429, -0.145729923014791, 0.665726789566798, 2.07077952406642, -1.53160552935134, 0.260140669203414, -0.354389579720782, -0.880136811861489, -1.73940938763137, -0.653654178790113, -2.02057611760712, 0.107381917921079, 0.176509936768009, 4.66364376034552, -0.384266247406289, -8.05280794333236, -0.473473669550119, -0.22009092358684, 0.471982780722334, -1.14862983963887, -0.345477817683903, -1.10455386319915, -2.26439807047638, -0.497479458526917, -6.62386103393725, 0.737871909405577, -5.59972422043153, -1.04585872629505, 0.851645104827465, -0.024300999166472, 2.02866605867842, 0.710014611908787, -0.437656804001136, 0.479322129923222, 0.614231679252136, 0.100843175865097, 0.981757579814104, 0.0533435707690026, -0.436004698474075, -0.728627809149687, -1.3455960869297, -3.45770557465564, 1.36472817955348, 0.77250598645642, 1.90565720312055, 0.491503617013778, 0.655038905013752, 0.877781862675545, 0.656220197803928, 0.957069876517388, 1.45570356016923, 0.870626276472197, 1.03698972088398, 1.45531939121849, 1.29691945663991, 1.03701843140314, 0.30412832825537, -1.47539080780684, 0.125546070883124, -6.26293033574947, -5.58912780569294, 0.49375232760385, 1.3392725471067, 1.31462186042328, 1.47134408703615, 1.0349801329787, 0.898332018057788, 1.34573393746072, 1.16865411023886, 1.00164756284456, 1.06164689889648, 0.654054308627981, -0.307843434976825, 1.2433360788338, -0.375514079601975, -0.859916995583392, -0.933607480932669, -1.94397184170948, -1.02383958152424, -0.0822671636073955, 0.761772242130567, -0.0322412205584391, -0.93561370494715, 0.0355700211561725, 0.123354416484441, 0.620127856146004, -0.506070831037792, -0.252540914156587, 0.118699493378956, 0.411482696746033, 0.381882242925506, 1.17481786697446, 0.191986879132848, 0.281660161140424, 0.276828603368229, -0.0165939025926863, -0.901473209272673, -0.0786561374756768, -5.64304520553749, -1.18990827347873, 8.83190026265947, 0.99596112723802, 0.639314953308649, 0.145651904903107, 1.68848366880681, 0.709549116220173, 0.794076148447284, 1.69825357894899, -1.70480701114046, 0.0641288315786146, 0.311418880881956, 6.18537317221478, 0.951462754972974, 0.503819292501282, -0.603815253238222, 0.169905537296221, 1.42829116600036, 1.36599488578331, 0.206187497307935, -0.893402278417459, -0.661818165985605, 0.408066754377194, -1.0119300429846, 0.398130288771763, -0.778820710467671, -0.14492928433536, 1.03214292596749, -0.42875455723597, -1.02332722395891, 0.431623647383189, -0.839727448827881, -0.606386323624282, -0.0408645039674532, -1.14236866347815, -1.08834807370416, -0.891087470698212, -1.32424886001153, -0.990266009736163, -0.699252162661518, -0.335989120441702, -1.08271057284286, -1.31168912620499, 2.53685687474027, -1.08316840066793, 2.13517453833715, 2.89482579144518, 0.994755961929098, 1.09093308657261, 1.90929092408626, 0.735166914427706, 1.24278216282647, 1.48190791868422, 0.681426483136772, 0.528544691130735, -1.63981361113545, -1.1024145716157, -0.777548200801553, -0.779832768521979, -0.925610911973686, 1.57429751091667, 2.40297589683478, 0.964172086790592, 4.42127189557637, 0.495031596240481, 0.247764057184193, -0.887966403690736, -1.28255283281329, -0.887513090330631, -1.13142443218222, -0.849703986783566, -0.841274727256044, -0.0695734156095085, -0.245085657093046, 0.0243354384540441, -1.12096055262357, -0.164487484148602, -0.668521147250858, 1.39828689657999, -1.3438888908589, -0.590534611362953, -0.976845812789321, 0.402981445026845, -0.338926343100151, 0.766481474313542, -0.590497791200817), .Dim = c(85L, 4L), .Dimnames = list(NULL, c("PC1", "PC2", "PC3", "PC4")))

@davidcsterratt davidcsterratt changed the title intersectn intersectn gives a different output to "a different function" Aug 31, 2024
@davidcsterratt
Copy link
Owner

Apologies for the long delay getting to this issue. I can't really do anything about this bug without knowing what the "other function" is. I'll close the issue for now, but do feel free to reactivate.

@MLIrstea
Copy link
Author

MLIrstea commented Sep 2, 2024

Here the two methods.

inter is the function I used and that was taken from betapart old releases.
`
library(rcdd)
library(geometry)

inter <- function(set1, set2) {
set1rep <- d2q(cbind(0, cbind(1, set1)))
set2rep <- d2q(cbind(0, cbind(1, set2)))
polytope1 <- redundant(set1rep, representation = "V")$output
polytope2 <- redundant(set2rep, representation = "V")$output
H_chset1 <- scdd(polytope1, representation = "V")$output
H_chset2 <- scdd(polytope2, representation = "V")$output
H_inter <- rbind(H_chset1, H_chset2)
V_inter <- scdd(H_inter, representation = "H")$output
vert_1n2 <- q2d(V_inter[, -c(1, 2)])
coord_vert_inter <- rep(NA, ncol(set1))
vol_inter <- 0
if (is.matrix(vert_1n2))
if (nrow(vert_1n2) > ncol(vert_1n2)) {
coord_vert_inter <- vert_1n2
vol_inter <- convhulln(vert_1n2, "FA")$vol
}
res <- list(coord_vert_inter = coord_vert_inter, vol_inter = vol_inter)
return(res)
}

inter(setu, setv)$vol_inter
[1] 388.0913

intersectn(setu, setv)$ch$vol
[1] 0
`
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants