00:00
00:00
Newgrounds Background Image Theme

Kheyindae just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

D. DeFonseca (2023)

Share

In the End I Studied PHYSICAL SCIENCE of all things, But


I've wasted so much time. I studied art when I was 20-23, and ended up giving it all up to do a physics and chemistry degree that I am at the end of now 27 years old and working in teaching math. I wish I could have known the things I did back then ... do you remember listening to the sleepy cabin podcasts? its the one thing I tend to associate with Newgrounds, and it feels like a life time ago, yet its still vivid in some parts.

I'm still happy that I did have the years in which I studied art and animation, even thou it ended in a small tragedy / fu*k up of my own design, hopefully I can make it right now.


Nowadays

most of my creative outlet only exists, at least for now, in the margins of my assignments (I cant draw pictures in my work documents and give that to my boss, although it would be interesting)...


iu_950680_4726669.webpiu_950681_4726669.webpiu_950683_4726669.webpiu_950682_4726669.webpiu_950684_4726669.webpiu_950685_4726669.webpiu_950686_4726669.webpiu_950687_4726669.webpiu_950688_4726669.webpiu_950689_4726669.webp


...and some other forms like code that I didn't think I would actually enjoy or be good at until now, but I never had a motivation before. I suppose that with an end goal in mind there is more reason to put in effort, and actions that where a means to an end become the the focused of attention later as their value is recognized.


Include/import

'''
pyproj.py
------------
04/04/2023
'''

#inner product
def innP(u,v):
    """len(u) = len(v) must be true, and also both\\
    vectors u and v must be float or int type array/lists."""
    sca = 0.0
    try:
        for i in range(0,len(u)):
            sca = sca + float(u[i]*v[i])
    #handle errors if possible.
    except Exception as expt:
        print("---->",expt,"<----")
        if (len(u) != len(v)):
            print("inner product = <u,v>\n\
u: |[ ",' , '.join(str(i) for i in u)," ]| = ",len(u),"\n\
v: |[ ",' , '.join(str(i) for i in v)," ]| = ",len(v),'\n',sep='')
        raise expt
    #else if no errors, then return scalar <u,v> = sca.
    else:
        return sca 
    #//
#//

#projection
def proj(u,v):
    result = [j * innP(u,v)/innP(v,v) for j in v]
    return result
#//

#normal reflection of u on v
def nrmlRefl(u,v):
    """reflect vector u about the normal vector v"""
    u_Rv = u
    u_Pv = [ 2*j for j in proj(u,v)]
    for i in range(0,len(u)):
        u_Rv[i] = u[i] - u_Pv[i]
    return u_Rv
#//

'''
from math import sin,cos,atan2,pi,tau

def deg2D(theta,phi):
    u=[cos(theta*tau/360),sin(theta*tau/360)]
    v=[cos(phi*tau/360),sin(phi*tau/360)]
    w=nrmlRefl(u,v)
    return round((atan2(w[1],w[0])*360/tau),8)
'''

Main file

'''
Assi1_1.7.12.py
------------
Assignment 01
exercise 1.7.12 (page 35)
05/04/2023
'''
from math import *
from turtle import *
import random
# my own library/python module 'pyproj.py' :)
from pyproj import nrmlRefl
import turtle

def deg2D(theta,phi):
    #vector of the turtles dirrection, based of of the angle (deg-->rad)
    u=[cos(theta*tau/360),sin(theta*tau/360)]
    #vector of walls normal, based of of the angle (deg-->rad)
    v=[cos(phi*tau/360),sin(phi*tau/360)]
    #reflect about normal, angle of incidence equals angle of reflection.
    w=nrmlRefl(u,v)
    #give me the reflection angle, based of on the reflection vector (rad-->deg)
    return round((atan2(w[1],w[0])*360/tau),4)

def f(x,moth,k,c,b = False):
    if(not bool(b)):
        m = moth
        return m*(x-k)+c
    else:
        theta = moth
        return tan(theta)*(x-k)+c

def f_inv(y,moth,k,c,b = False):
    if(not bool(b)):
        m = moth
        return (y-c)/m + k
    else:
        theta = moth
        return (y-c)/tan(theta) + k

#the angle to test
phi = 60
radphi = phi*(tau/360)
rd = 320
Ox = -180

def move(distance):
    """Move forward and bounce of the box edge"""
    forward(distance)
    theta = heading()
    Z=f(xcor(),radphi,rd+Ox,-rd,1)
    # at boundary deflection/collision occurs.
    if (xcor() <= -rd+Ox or ycor() <= Z or abs(ycor()) >= rd):
        print("echo bunny0")
        nowspeed = speed()
        speed(0)
        if(ycor() <= Z and ycor() > -rd):
            print("echo bunny1")
            setx(xcor()-0.5)
            sety(ycor()+0.5)
            theta = deg2D(heading(),phi+90)
        elif(xcor() <= -rd+Ox):
            print("echo bunny2")
            setx(xcor()+1)
            theta = deg2D(heading(),0)
        elif(ycor() >= rd):
            print("echo bunny3")
            sety(ycor()-1)
            theta = deg2D(heading(),270)
        elif(ycor() <= -rd):
            print("echo bunny4")
            sety(ycor()+1)
            theta = deg2D(heading(),90)
        # angle_incidence = angle_reflection, but this only works in a box.
        # fine statistical randomness included to creat slight variation in the angle of reflection!
        rnd = random.uniform(-6.5,6.5)
        setheading(theta + rnd)
        #back to normal turtle speed.
        speed(nowspeed)
    #//
#//

# Bounce the turtle.
def main():
    screen = Screen()
    WIDTH, HEIGHT = 1080, 720
    screen.setup(width = WIDTH, height = HEIGHT)
    #screensize(canvwidth = WIDTH, canvheight = HEIGHT)
    hideturtle()
    penup()
    speed(9)
    setheading(115)
    pensize(12)
    goto(rd+Ox,-rd)
    pendown()
    goto(rd+Ox,-rd)
    goto(f_inv(rd,radphi,rd+Ox,-rd,1),rd)
    goto(-rd+Ox,rd)
    goto(-rd+Ox,-rd)
    goto(rd+Ox,-rd)
    penup()
    goto(0,0)
    """entry point function"""
    turtlesize(3)
    shape("circle")
    showturtle()
    pensize(4)
    #pendown()
    setheading(-15)
    speed(1)
    for _ in range(1000):
        move(10)
    #//
    exitonclick()
#//

#turtle 101
main()


I honestly didn't see myself doing this, nor did I ever think id be back here on Newgrounds talking to myself.

I should get back to work before the power goes out again.

Log in / sign up to vote & review!

mathematical masterpieces

Credits & Info

Artist
Views
65
Faves:
1
Votes
6
Score
2.88 / 5.00

Uploaded
Apr 17, 2023
6:57 PM EDT
Category
Illustration

You might also enjoy...

Licensing Terms

You are free to copy, distribute and transmit this work under the following conditions:

Attribution:
You must give credit to the artist.

* Please consider sharing revenue!