My personal Processing trap

Soo… I’m writing this coming off of yet another frustrating experience trying to get a sketch to work. It’s wordy and somewhat meta, so bear with me. Also, I have yet no idea, if I’m actually looking for answers or just need a place to vent.

Some background: I’m not new to Processing. I’ve dabbled with it for pure fun during the years, I’ve mastered the coding fundamentals, know how to write basic OOP, have a grasp on vectors and know how to translate cartesian to polar coordinates. All of it autodidact. I write my code using Sublime. My sketches run, but they’re not optimized or “good code” and thus I’d never call myself a programmer for doing so. Let’s call me an intermediate hobbyist.

I’ve recently noticed a recurring theme, whenever I begin writing a new sketch: Every time I give it another go, I end up rage-quitting after a few days. But my frustration isn’t so much with Processing, but with the math involved for writing more complex sketches. Any my lack of understanding that math.

Enter my most current sketch: I have circles moving around the screen. Whenever two circles intersect, I want to draw a line between the two intersection points. Simple premise, right? And I’ve got it working!

Buuuuuuut… I don’t really know why.

Like any coder, I ask duckduckgo/google and try to find help and hints on the mathy parts of a sketch, in this specific case, how to calculate the intersection points. As you know, there’s a plethora of sources out there: Wikipedia, Wolfram, StackOverflow, Khan Academy, OpenProcessing, and so many more. Between these, I’ll most often find enough input to make my code run. Or I might find a block of code I can pull into my sketch and with adjustments to formatting/variables/style get it to work.

With the current project, I eventually found some intersection-calculating code on OpenProcessing that I’m using in my sketch and which eventually made it work. The foreign code is even nicely commented, so I can read what every line of code does. I just don’t understand the math.

And here is when I begin to fall into the trap. I want to know how the math works. I know my Pythagoras and basic Trig, but for anything more I bump into a wall. Then I try to deep-dive every single line of code, trying to find out what it does EXACTLY. And I sink deeper and deeper into math I have maybe heard of before, but have zero experience with. Triangle Altitude. Standard forms. Heron’s formula. Slowly I manage to make sense of the lines of code. But some lines just remain completely opaque to me.

Sure, some stuff I remember from school – many moons ago. Some stuff I never ever touched upon. So I want to learn it all, but it feels like a bottomless pit. And every solution seems to have a far more elegant and general (and more complex) way of going about it. It never ends! All the while my level of frustration grows and grows. I also completely ignore that my sketch IS already working. But for some reason, I can’t manage to let go of the notion, that I don’t “own” all of my code without completely understanding every single line in it.

So this is it in a nutshell. I start writing a sketch but quit because I feel my math is not up to snuff and thus am a “cheater” for using someone else’s code.

  • Does anybody else fall into this trap?
  • How do you go about learning new math topics when you constantly run into unknown terms and notation?
  • When do you stop refining your sketch and just settle on code that, even if being somewhat wonky, DOES THE JOB JUST FINE.
  • How do you deal with using foreign code you have little idea of how it actually works?

Thing is, this may very much just be all me. But maybe someone feels the same sometimes and might have an idea for me on how to cope with this issue in the future?

Any input on this topic is highly appreciated.

5 Likes

Just so it’s not all boring, here’s the output from the sketch mentioned in my wall of text.

3 Likes

Perhaps, focus on your strengths rather than what you consider to be your weakness? I say that with some relateabilty…
:slight_smile:
I don’t consider myself a math person either. I am in awe of people who are.
However, it seems your dilemma stems from thinking you must have some level of expertise in math in order to truly enjoy the process of coding(?).
Interesting creations are often built under restrictions, be it lack of traditional materials or rudimentary knowledge of a subject.
:nerd_face: :nerd_face:

PS: Also, it’s not clear if you’re asking about math per se or what is going on behind the scenes with the code…

To clarify, I’m asking about the math per se. The inner workings of the underlying code I’m fine with not knowing the details about. :wink:

Interesting creations are often built under restrictions, be it lack of traditional materials or rudimentary knowledge of a subject.

I can get behind this idea. Restrictions can unearth some form of creativity that otherwise would have been glossed over. I’m – for the most part – also fine with writing code which is haphazard and deemed ”ugly" or unsafe by commercial IT standards.

Three things I still struggle with though:

One, I want my sketch output to work visually the way I intend it to work. If I instead manage to write something that approaches my initial idea but I need to compromise visual fidelity or take visual artifacts and inconsistencies into account, then I feel that I failed my concept. Granted, this is 100% my preference and if others don’t care that much about it, I have no issue with that.

Two, I have difficulty calling something “my creation” if the most vital part of said creation wasn’t made by me. So much so, that it makes me feel like a fraud. See the screenshot I posted above? The reason I’m able to create those visuals is because someone else cracked the most vital part of the sketch for me – the calculation of the circle intersection points. Without that code I’d have circles (invisible) whizzing around on screen and then draw a line from center to center of two intersecting circles. (See attached screenshot). I know how to write and understand all parts of that code. It produces a similar visual to what I have now, yet it’s not the same as my intent for this sketch. Saying “Oh well, that’ll do” just is not how I approach things.

Three, I’m all for happy accidents. I’m OK with serendipitous discovery. But only if I can recreate that result again with full intention. And I can explain all the steps along the way.

Yeah, I’m probably being my own worst critic…

2 Likes

This really resonates for me. It can also be intellectually productive to drill down into methods and master them – when it doesn’t halt productivity in the name of research and turn into bikesheddiing.

A code language document stands atop a huge stack of abstractions. How do I draw the letter “a” onto the screen at 12pt height? How do I antialias a single line stroke? How do I load a string into memory, and alter it? My sketch may do those things, but it won’t contain detailed answers on how it does them. When we look through the enormous code of Processing, we find that often that code doesn’t explain how it does those things, either – and it refers to OpenGL, or to Java libraries. If we read that code, it also may not answer such questions. Instead it may import further libraries, for example, to handle math or system calls. As we descend, C libraries still contain references to things we don’t understand that depend on drivers, chip architectures, or voltage differences…

I belabor all that in order to raise this question of how comfortable we are with what is given and what is not. Why should I be uncomfortable about collision, specifically? Why not any of the hundreds of other kinds of math that my sketch is doing that I did not write and might not fully understand? For me it partly has to do with the way that my sketch encapsulates code and presents it as either written by me, or imported from some commons, or perhaps borrowed from someone more specific.

If the processing PShape object came with PShape.collide(), and it magically solved your collision problem, then you might not consider collision core to your intellectual labor (any more than you do alpha transparency), and it might not even occur to you to be anxious about it.

If alpha was not built-in, suddenly my making it work in my sketch might feel like a vital Herculean task, with tons of ugly blendMode math harvested from StackOverflow posts, and much angst. But instead I have blendMode() – and it is there, working in the background, even if it is never mentioned in my sketch code. So I focus my angst on other things.

One way to work with subjective feelings about legitimate authorship is to make them explicit. This is really more of a psychological trick, but it might work for you. If you want to have a sense of legitimate authorship that isn’t distracted by the collision issue:

  1. create a second tab – name it CircleCircle
  2. define the method or class that implements circle-circle collisions in a way that you don’t understand – and don’t necessarily need to!
  3. add an author/reference credit to the top of the file – it isn’t by you.
  4. use CircleCircle – somebody else’s code – from YOUR code in the main sketch, no different from importing peasyCam or G4P (or Processing, which is silently imported by every sketch).

One final thought on “vital”. We creators are often poor judges of what “the most vital part” of a creation is while we are making it (or at least I am in my personal experience). When we ask others what they think is vital about a creation, most of them simply don’t care whether we as the creator understand circle-circle collision! That can be disappointing when we labored hard to do so, but there it is.


P.S. For what it is worth, I wrote a whole collision library a few years back, in part by learning each equation from tutorials by great teachers like Jeff Thompson and Kevin Workman. A couple days ago I learned for the first time that one of the simplest components of them all – LineLine – didn’t work the way that I thought that it did! So I try to keep a sense of humility, even about the parts of my sketches that I have “mastered”.

4 Likes

When Leonardo da Vinci finished the Mona Lisa did he step back, look at it and think “I can’t take credit for this because I didn’t make the most important parts, the canvas, the brushes, the paint…”. I think not.

Yes the calculation is important but it is definitely not the most important part, that is what you have done with it - the beautiful visual created by your sketch.

I am an experienced programmer and good at maths but I have my own limits in these areas - so many, many times I have to rely on other peoples work for ideas or even code. Most of my current projects are written in Java so I use hundreds of megabytes of code created by other developers over several decades, it does not detract from what I produce.

Sometimes I have to give up when my math skill lets me down. One project was the calculation of the intersection points of two translated and rotated ellipses even after several days of effort I still didn’t manage it sigh…

So carry on and use whatever math solutions / libraries others provide without concern, its what you do with it that’s amazing :smile:

3 Likes

I think I start with quite vague ideas of what I want from a sketch, so if it all lead me to something else it doesn’t bother me that much. I have programmed for living in the past and Processing was for me a way to get used to programming again. Sure I need to learn how processing works, besides reminding myself how to programs are built. With Processing I started with photos and how to glitch or break them. My approach from the start was to fail. If program created an interesting image, but my mistake it was fine.

I don’t always have the luxury to just go where imperfect programming takes me. I’ve studied data science for two years now and returning an exercise that is somewhat similar to what was required just doesn’t work. About a year ago I did still get irritated when things didn’t work smoothly and I had to stop and study and investigate things a bit deeper. Later I have realized that it usually means I’m trying to do things in a wrong way. I cannot say that need to dig deeper in to maths, would be the same thing, but it could be. Problems are the best way to learn.

So for me doing art is all about visuals and esthetics. How got there is mostly irrelevant. As @jeremydouglass pointed out with computing we rely all the time on work of others. I quess it’s a question of control. To what extent we command control over the code we use to create the visuals. I have programmed when you had to do (almost ) everything yourself from the scratch and I don’t want to go back there. I really like comfort processing gives to me. I can concentrate on the interesting stuff and I don’t have to spend hours or days to first build routines I need to draw points, lines, squares etc.

So a need to dig deeper tells me I need to stop and think if I’m doing things in the right way. Most of the problems you will ever run into have already been encountered by many programmers before you and they have put that information into modern programming languages (including processing) and libraries. Or to instructions in the internet. Problems will not disappear, but they always offer an opportunity to learn. And learning means you’ll do things better next time around.

You weren’t sure if you asked a question. I’m not sure if I answered anything :grin:

2 Likes