|
LP0 ON FIRE posted:Sort of a math question, but in java script: I remember someone telling me before a few years ago how to make a simple oscillator function without using sine. I think it just uses addition and subtraction. Anyone know what this is? You want a second order IIR filter http://www.ee.ic.ac.uk/pcheung/teaching/ee3_Study_Project/Sinewave%20Generation(708).pdf
|
# ? Feb 2, 2017 19:33 |
|
|
# ? May 16, 2024 18:21 |
|
Eela6 posted:It's got to be the Taylor series , as mentioned. P.S: how do you think sin() is implemented under the hood? With great difficulty: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/ieee754/dbl-64/s_sin.c;hb=HEAD#l281 (or as CORDIC if you're on fixed point)
|
# ? Feb 2, 2017 19:41 |
Well, I've got egg on my face.
|
|
# ? Feb 2, 2017 19:42 |
|
Eela6 posted:It's got to be the Taylor series , as mentioned. P.S: how do you think sin() is implemented under the hood? Probably something similar to this.
|
# ? Feb 2, 2017 19:48 |
|
The Laplace Demon posted:Check out the equations in the section titled "Block Behavior in Discrete Mode": https://www.mathworks.com/help/simulink/slref/sinewave.html Yes! This is it. I also found it in some old code to make waves in water. HappyHippo posted:Why do you want this? If it's for "speed" I recommend sticking to sine unless you can prove that's what's slowing you down. I didn't like the idea of a number continuously increasing and applying the math for sin on a larger and larger number.
|
# ? Feb 2, 2017 19:54 |
|
LP0 ON FIRE posted:I didn't like the idea of a number continuously increasing and applying the math for sin on a larger and larger number. So range clamp the number or use modulo if it bothers you?
|
# ? Feb 2, 2017 19:58 |
|
LP0 ON FIRE posted:I didn't like the idea of a number continuously increasing and applying the math for sin on a larger and larger number. Just do x = x % (2 pi)
|
# ? Feb 2, 2017 20:02 |
|
Munkeymon posted:So range clamp the number or use modulo if it bothers you? If you range clamp it, it's questionable what it should reset back to. HappyHippo posted:Just do x = x % (2 pi) That's throwing in operations that are more expensive than a simple oscillator.
|
# ? Feb 2, 2017 20:07 |
|
LP0 ON FIRE posted:If you range clamp it, it's questionable what it should reset back to. If you're concerned about the runtime of the modulus operator, then I drat well hope your target platform is, like, a calculator. A TI-83+, maybe.
|
# ? Feb 2, 2017 21:32 |
|
TooMuchAbstraction posted:If you're concerned about the runtime of the modulus operator, then I drat well hope your target platform is, like, a calculator. A TI-83+, maybe. It's not always the target platform, but also how much you are using it!
|
# ? Feb 2, 2017 22:27 |
|
LP0 ON FIRE posted:It's not always the target platform, but also how much you are using it! Have you determined that in fact the computational cost of using library trig functions is imposing an unacceptable penalty on your performance? In other words, are you prematurely optimizing? (And if not, what the hell are you doing to a modern computer that you can't afford to call sin()? )
|
# ? Feb 2, 2017 22:31 |
|
I'd like to point out that modulo by a fixed dividend can often be optimized by the compiler into something more efficient. I mean, you're using floating point, so uh... that ain't happening, but if it was some fixed point thing...? Actually: x `fmod` y is just x - trunc(x * (1 / y)) * y So yeah, you could imagine avoiding an actual division operation, and just using multiplication by constants 1 / (2pi) and 2pi. Edit: And looking at some sources, some of them compute it with like, integer ops and stuff to avoid intermediate rounding error and I bet it's real slow. sarehu fucked around with this message at 22:36 on Feb 2, 2017 |
# ? Feb 2, 2017 22:32 |
|
LP0 ON FIRE posted:It's not always the target platform, but also how much you are using it! Have you profiled your code and figured out that trig math is causing it to be slow, or are you just assuming?
|
# ? Feb 2, 2017 22:33 |
|
Jabor posted:Have you profiled your code and figured out that trig math is causing it to be slow, or are you just assuming? I'm assuming based on something I already tried it with and got a performance boost, but this is lighter, and maybe it won't matter as much. sarehu posted:Actually: x `fmod` y is just x - trunc(x * (1 / y)) * y The question there though is what is y, and if you had a lot of those as semi-large numbers, wouldn't you start taking a performance hit especially with the division?
|
# ? Feb 2, 2017 23:08 |
|
LP0 ON FIRE posted:I'm assuming based on something I already tried it with and got a performance boost, but this is lighter, and maybe it won't matter as much. Y is 2π, which is the point where trig functions have gone all the way around the circle and started repeating. The trick with dividing by a constant is that you can actually calculate 1/y at compile-time, and so at runtime it's still just another multiplication.
|
# ? Feb 2, 2017 23:16 |
|
Jabor posted:Y is 2π, which is the point where trig functions have gone all the way around the circle and started repeating. That's true, except in the case where y is changing every time the function is called.
|
# ? Feb 2, 2017 23:21 |
|
LP0 ON FIRE posted:That's true, except in the case where y is changing every time the function is called. What are you actually trying to accomplish, because based on your comments either it's very weird or you're doing a poor job conveying what you want. Like, what other values of Y could you possibly want to use, here, in the context of trig functions?
|
# ? Feb 2, 2017 23:24 |
|
No I'm retarded and read your explanation wrong that y is 2π and can and 1/2π can just be calculated at compile time. When I was making something in Obj-C that made 2d water waves in OpenGL, I stuck with using the simple osc because I got a performance increase, and now I want to revisit why. I want to recreate something like that in JS, and use sliders to edit the parameters and such. The original code uses a ton of points with spring physics, and you can throw objects into the water to have it react at a certain point to create stronger waves around the impact that dissipate.
|
# ? Feb 2, 2017 23:52 |
|
With JS I don't think your performance bottleneck is going to be sine vs. something else, but ultimately you have to test it to check. Spring physics shouldn't require sine/cosine though? Hook's law just requires squaring.
|
# ? Feb 2, 2017 23:57 |
|
HappyHippo posted:Spring physics shouldn't require sine/cosine though? Hook's law just requires squaring. Hooke's law
|
# ? Feb 3, 2017 00:06 |
|
Damnit. And I have a physics degree too
|
# ? Feb 3, 2017 00:12 |
|
HappyHippo posted:With JS I don't think your performance bottleneck is going to be sine vs. something else, but ultimately you have to test it to check. It does to make the water appear to be constantly moving. Kinda like the water in the New Super Bros Wii.
|
# ? Feb 3, 2017 03:01 |
|
Hello, all. I'm kind of just starting out learning to code, and I'm currently working on a small project. Posting it in here because it's probably not too difficult if you know what you're doing (I don't, really) and so doesn't really need a thread of its own. That, and I don't really know what type of code would work best for it. HTML or Java, maybe? Some background details: I'm trying to build a sort of search engine(?) for the Battle Network games. The series uses "battlechips" as the main game weapons, with 4-6 different versions of each battlechip that all have different values. (27 different possible values, one for each letter plus the asterisk.) IE - The chip Widesword can have the value of either C, E, L, Q, or Y; the chip Slasher can have the value of either B, D, G, R, or S; etc. What I want is to be able to say, select "L" on a drop-down list, and have the program display every chip with the value of "L". I need to know how to assign multiple values (ie - Widesword:CELQY) to a single data entry, and how to make the code access a separate database of all those data entries and pull out the correct one. In the end, I want to make it display something like this, listing every data entry meeting the criteria of "L".
|
# ? Feb 3, 2017 08:58 |
|
You can do that kind of thing in any language and some things that you might not even call languages really! So a better question is how do you want to use this? Is it going to be a website? Or a downloadable thing that runs on your computer? Who's going to use it? Are there any technologies you're interested in learning? HTML and JavaScript (I think you meant that instead of Java, you can use Java too though) would be a good choice for this kind of thing if you're into that - it's easy to get immediate results. Python is decent as an introduction to coding and working with data, but it's not as easy to get stuff looking pretty in a browser But yeah really your options are wide open here, unless you have some specific requirements. Knowing what else you want it to eventually do might help as well, storing and retrieving data is sort of the basic stuff you can do with anything e- oh yeah, just to give you an idea, you'd generally store your data (all the chips) somehow, including their letters, and then have some function that looks at them and pulls out the ones you want. That could be as simple as storing the letters as a string of characters, looking at each in turn to see if the chip you're looking at has the letter you're interested in, to fancier ways of structuring and filtering your data, to sticking it all in a proper database and running a simple query that pulls out exactly the records you want. Lots of ways to tackle the problem, if you start doing some tutorials for a language you'll start to get ideas of how to do it baka kaba fucked around with this message at 11:01 on Feb 3, 2017 |
# ? Feb 3, 2017 10:45 |
|
So, graph databases: I know, they're beloved of data scientists and other non-programmers, but they're actually useful. We (a bunch of biologists) are using them to build interaction graphs of molecules (like many other bunches of biologists) to work out causation and interference. But there's so many graph implementations out there that it's ridiculous. The most popular tool appears to be Neo4J, which in terms of getting a graph up and going is certainly the most straightforward and user-friendly. But: - The scaling or distributed solutions are poor - They really push you towards their query language, Cypher, rather than something more portable and programmable like Gremlin. (And I was having huge trouble with their official Python module, creating nodes in code that just never seemed to propagate to the actual db.) - One graph per database, one database per server. If you want a second graph, make another server. - I want to do some fairly sophisticated traversal and I'm finding it hard in Neo4J Then there's the whole property graph versus triplet issue. I find the property approach more intuitive but lately triplets are seeming more logical. So, what are people's favourite graph platforms? What issues should I look out for?
|
# ? Feb 3, 2017 11:10 |
|
I'm trying to scrape some web data. I trimmed the fat off the URLS, but I still don't understand the date formatting. Anyone recognize this? code:
|
# ? Feb 3, 2017 15:18 |
|
Squashy Nipples posted:I'm trying to scrape some web data. I trimmed the fat off the URLS, but I still don't understand the date formatting. Hexadecimal encoding of a unix timestamp. http://www.wolframalpha.com/input/?i=583E5CD0+base+16+to+base+10 https://unixtimestamp.org/1480482000
|
# ? Feb 3, 2017 15:19 |
|
Ok, Thanks! It looked like hex, but I didn't understand the capitalization.
|
# ? Feb 3, 2017 15:21 |
|
Squashy Nipples posted:Ok, Thanks! My guess? Someone was sloppy with their hex generation code.
|
# ? Feb 3, 2017 15:23 |
|
outlier posted:So, graph databases: I've been looking at Cayley for a project I'm working on, but I'm constrained because it's for corporate use and we don't want to pay for a commercial license. There may be something better out there for academic purposes.
|
# ? Feb 3, 2017 15:49 |
|
carry on then posted:My guess? Someone was sloppy with their hex generation code. I had to fiddle with the date a bit, because the report is daily, and doesn't actually have a time, but I've got my function doing what I want now. code:
|
# ? Feb 3, 2017 16:08 |
Blaziken386 posted:Hello, all. I'm kind of just starting out learning to code, and I'm currently working on a small project. Posting it in here because it's probably not too difficult if you know what you're doing (I don't, really) and so doesn't really need a thread of its own. That, and I don't really know what type of code would work best for it. HTML or Java, maybe? You can do this in pretty much any language. I would personally recommend Python 3 as a starter language, especially for something like this. Java is a language with a lot of boilerplate code that beginners often find frustrating. (Also, I just love Python.) The Anaconda Distribution will give you everything you need to get up and running in Python. It even has a built-in IDE, Spyder, which I find to be excellent for beginner programmers. It makes it easy to see and correct your mistakes.
|
|
# ? Feb 3, 2017 16:30 |
|
Squashy Nipples posted:
I hope this one is a typo, because otherwise it's a really weird bug.
|
# ? Feb 3, 2017 16:41 |
|
ulmont posted:I hope this one is a typo, because otherwise it's a really weird bug. Yep, fat finger. Hadn't built the scraper yet, was just pasting in URLs and looking.
|
# ? Feb 3, 2017 17:02 |
|
outlier posted:So, graph databases: A project I was on very briefly was using Titan for graph queries on supposedly big datasets. Titan is a distributed system for tinkerpop graphs, which uses Gremlin and seems to be pretty capable of complex queries and support for many languages. piratepilates fucked around with this message at 18:25 on Feb 3, 2017 |
# ? Feb 3, 2017 17:51 |
Blaziken386 posted:Hello, all. I'm kind of just starting out learning to code, and I'm currently working on a small project. Posting it in here because it's probably not too difficult if you know what you're doing (I don't, really) and so doesn't really need a thread of its own. That, and I don't really know what type of code would work best for it. HTML or Java, maybe? So to give you an example of where to start, I took this wiki page on battle network 2: http://megaman.wikia.com/wiki/List_of_Mega_Man_Battle_Network_2_Battle_Chips I scraped the data http://pastebin.com/0T9E8R2s I cleaned it up using this script http://pastebin.com/EcW5maSC and I outputted it to CSV http://pastebin.com/eGEm36QA (you might want to start here!) There's also some other example code in there that might help you on your way. I would try and work on your project in three steps. 1: Build your database of all the battle network games (probably by scraping and cleaning fan wikis) 2. Build a series of functions that give you the data you're looking for as text 3. Learn how to build a basic web-page and GUI that gives you access to that data (I recommend flask). Anyways, if you don't end up using it, no big. I enjoyed this little project. Eela6 fucked around with this message at 18:22 on Feb 3, 2017 |
|
# ? Feb 3, 2017 18:17 |
|
piratepilates posted:tinkerpop, Gremlin I'm trying to imagine having a serious conversation about adopting graph databases at work and having to use these words in a group of adults
|
# ? Feb 3, 2017 20:46 |
|
redleader posted:I'm trying to imagine having a serious conversation about adopting graph databases at work and having to use these words in a group of adults You think just the names are bad? Take a look through the tinkerpop documentation first.
|
# ? Feb 3, 2017 21:12 |
|
redleader posted:I'm trying to imagine having a serious conversation about adopting graph databases at work and having to use these words in a group of adults "Software with extremely stupid names" is a nearly endless trail of woe.
|
# ? Feb 3, 2017 21:55 |
|
|
# ? May 16, 2024 18:21 |
|
piratepilates posted:You think just the names are bad? Take a look through the tinkerpop documentation first. Christ, you're not kidding.
|
# ? Feb 3, 2017 22:38 |