CNMAT / CNMAT-Externs

CNMAT Max/MSP externals
Other
96 stars 11 forks source link

xydisplay - phase input, interpolated point disapears #138

Open damienjacquet opened 1 year ago

damienjacquet commented 1 year ago

I use xydisplay to create trajectories in a spatialization software to move a sound source. when interpolating the points to place the source along the trajectory, the interpolated point sometimes disappears. -nan(ind) is give as a y coordinate

image

here is an example patch of the bug: bug_xydisplay_interpolated_point_nan.txt

https://user-images.githubusercontent.com/113354591/203826905-4e3cf731-acbe-427d-be1c-f03c6296d2ce.mov

wagne342 commented 1 year ago

@damienjacquet Thanks for this and apologies for the late reply. This is indeed a bug. The root of the issue in your example seems to be that the x-coordinates for both points 5 and 6 are identical. In the code, this leads to a divide by zero, resulting in NaN being returned. The problem is actually worse than this; it appears that the y-values that are returned by interpolation are incorrect.


----------begin_max5_patcher----------
1064.3oc6Y00iiaBE84jeEH+blHCXig9V+YTUUMh3vLkUNXKLY1jc09eu7gS
hSi2Xudcr1nVOZLBLlKmKW3btNec4hnMkGD0QfeC7mfEK95xEK7M4ZXQS8EQ
63GxK309tEkWtamPYhVEdlQbv3a+Od4CdwdQMfqEf7RUsr1X6WwQfTkWp0hb
Cfq1BpzkJAvTB1J+PtU.1bD7EgtDHz5Rc8ogsPpD4k6U9wF2zXkVTaGRtQVp
dsydn1uSpJDF+TEdowx8lSsFeZv3l7+Vpd+U2LK3.RfYqiWAn3r0oq.vzXWs
Daaf+p4kja8XsbymdAmD4Z6aKW5ts5+8djLXvegFh2C+j48947MPVh2aPXth
97Mnw3aThOae4abMUZ4EG1OGHvD5ZbqKTJ0tYIyCILxcGg5FQnzwfnch5Z96
hafT7ZP7ZHhfYIcBLTm.6DbCMYNVIBnJJ57LtqENZxZVqKJkbFyPH6tflLFP
+VQocdGcdFo46DFg9UghuoPzdEZ.KlnuKlWAh1vUueWrmR7QozTWQHj8Jr9V
odG22WRGnOaJWxqEFPr6u0P+cDH9wuzC8PNE4wOLN8tK1zoDt4EBtdEPKr3X
iP+3gJ1uTmR76hY2euLaLH8vwsx5pB9wnyAOJSs7K9oGzYvPya07OWUJCm8R
SoLFNIkgG61AmUT1WwOG9csjWD0oaK4jAbltQNjMJaEHD06JgMUNUFt0Zyfx
7FO+poTma6N++.h8HPOsAJPafvosVRbdpB9FQwU.tMMR7ulzHTK1tgFIAmM.
ZD7jSifozjLxCeCFAQtkFoAy8Qij7jSijvnddD7nnQPO.ZjKjHtHfnd0Gidz
gGoonPhGg3g6yz.elYZRy7ACPT7.XZh+OCSimOA2vz3qfZyz.ebLMMgdvLz3
YZfreQSXA1bxy.3VfSp.ts62U8v2KghwWN0.eWRDX5zeLp6PT2Qn3Gu7z3jf
DbuJU5cOdDhepEhS8eCEXBr+iGgihHfaL58xS.wUKDvdYO9znYXj5jngSgZ8
UR9dvmMkqyuXECp3pYHQqj0j1WH1P0ARexkAFRil.GiJPxjHD3f8wdbDeVDv
PzFjfXILRFhkcdbjJ2Cdo0.M+5EvmyL0U1NyT30YldraXOcRHBaZ+wUPbrC+
Xa4esWz8Ck+Ky9u9wJ7yGW6WGITWtWmeBIMe1h1NkshZiT4052pS1Tl8cpyn
sAaI5rYor4xR9AA0ikP17nspBl.Kg6yRoS.lfrgXI7TYod8dISf2yltb+QDP
1TD6AmMKEOWVhL.Cgl.6vlI6.gyjgPCH9lNAg2P7b44RmQOWemAAo2Xn.cHu
p5Cgtto2daXk.8oRujd5JeUoJT0+gMhzhOjm5umFNhqsz4FKW9dcPKxAR3WU
KZW4VgVYyUv02kNzYMoWdkS2RcUi9AuJrkea4+.Sh1ED
-----------end_max5_patcher-----------

TODO: in xydisplay.c the xy_scale method needs to check for scenarios where inputs will result in divide by zero.

TODO: find the source of inaccuracy in y-value interpolation

wagne342 commented 1 year ago

I have attempted a tentative fix for this issue pending review by @maccallum, who is the original author. In the meantime, try it out below.
xydisplay.mxo.zip

damienjacquet commented 1 year ago

thank you for the fix, I will test it as soon as I can

damienjacquet commented 1 year ago

@wagne342 Do you have a .mxe64 version of the objects ? I would like to test it on windows

maccallum commented 1 year ago

@wagne342 that fix looks good to me