Michdd Posted December 21, 2008 Share Posted December 21, 2008 I have a layering thing, now I'm laying something on top of something else, and the images that are going on the base when I set the x to the x of the base that works fine, the y is a little more variable. The Y value of the upper layer item is something like this: base y value - some number. It varies from item to item being layered. I need a formula that will generate the number that needs to be subtracted to correctly layer the objects. I have the results for the size of the image being layered, and the result of how many px needs to be subtracted to make it work for 3 different items, so I need a formula based on this, I've tried, but I can't seem to think of anything: Results: Image size: 53px. pixels needed to be subtracted from the Y Axis to layer correctly: 2px Image size: 46px. pixels needed to be subtracted from the Y Axis to layer correctly: 7px Image size: 45px. pixels needed to be subtracted from the Y Axis to layer correctly: 6px Link to comment https://forums.phpfreaks.com/topic/137880-solved-getting-a-correct-difference/ Share on other sites More sharing options...
corbin Posted December 21, 2008 Share Posted December 21, 2008 So how exactly do these three objects fit together? Link to comment https://forums.phpfreaks.com/topic/137880-solved-getting-a-correct-difference/#findComment-720586 Share on other sites More sharing options...
Michdd Posted December 21, 2008 Author Share Posted December 21, 2008 So how exactly do these three objects fit together? Those don't it together, that was 3 different examples. One of those images at a time fits over the base. So for item 1 over the base it gave me the first results, item #2 over the base gave me the 2nd results etc... So I need a formula that will generate the number needed to be subtracted (or added) so that it will work for all those (and more) Link to comment https://forums.phpfreaks.com/topic/137880-solved-getting-a-correct-difference/#findComment-720588 Share on other sites More sharing options...
Mark Baker Posted December 21, 2008 Share Posted December 21, 2008 Trying to extract a relationship/formula from only three values isn't easy. 53px + (2 * 2px) = 57 46px + (2 * 7px) = 60 45px + (2 * 6px) = 57 Nope, don't work... unless the 7px for 46px should really be 4.5/5px Can you post a few more examples and expected result, then we might at least be able to determine a trend. Link to comment https://forums.phpfreaks.com/topic/137880-solved-getting-a-correct-difference/#findComment-720641 Share on other sites More sharing options...
Michdd Posted December 21, 2008 Author Share Posted December 21, 2008 Trying to extract a relationship/formula from only three values isn't easy. 53px + (2 * 2px) = 57 46px + (2 * 7px) = 60 45px + (2 * 6px) = 57 Nope, don't work... unless the 7px for 46px should really be 4.5/5px Can you post a few more examples and expected result, then we might at least be able to determine a trend. Here's another one: 32px and it has to subtract 9px from Y to fit correctly. Also the first numbers are rounded, they're really .05 less, so 32px is really 31.95 if that helps. Link to comment https://forums.phpfreaks.com/topic/137880-solved-getting-a-correct-difference/#findComment-720814 Share on other sites More sharing options...
Mark Baker Posted December 21, 2008 Share Posted December 21, 2008 It gives me some data for testing my own current projects.... best fit trend lines in PHP. So far I have X Values Y Values 52.95 2 45.95 7 44.95 5 31.95 9 Linear is the best fit from those 4 data points, giving a 81.9% fit But it's still that 46px value giving 7 that's throwing it. If we discard that, then the other three points give a 99.7% fit for a simple linear equation of: y = -0.330860534125 * x + 19.6540801187 Link to comment https://forums.phpfreaks.com/topic/137880-solved-getting-a-correct-difference/#findComment-720851 Share on other sites More sharing options...
Michdd Posted December 21, 2008 Author Share Posted December 21, 2008 I solved this problem another way, thanks for all your help anyways. Link to comment https://forums.phpfreaks.com/topic/137880-solved-getting-a-correct-difference/#findComment-720854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.