Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - spoon

Pages: [1]
Technology & Information / cool fun programming stuff
« on: April 27, 2015, 03:20:30 AM »
Code: [Select]
from __future__ import division
from visual import *
from random import *

#define constants and other parameters

number = 8 #number of charges
q = 1.6e-19 #1 unit of charge (charge of an electron)
k = 9e9 # k (1/4piEnaught)
rad = 100 #radius of spherical region
shrink = 1.75 #used to make sure all charges begin within the sphere
zero = vector(0,0,0) #used for declaration purposes
electrons = 7e11*(1/number) #puts a lot of charge on each charge carrier
d = .5 #damping effect the inside of the sphere has on the charges (not used)

#generate translucent spherical region
item1 = sphere(pos = (0,0,0), radius = rad, color = color.white, opacity = .3)

#generate axes for clarity in charge position and depth within the sphere
xaxis = curve(pos = [(-1.5*rad,0,0),(1.5*rad,0,0)], color =, radius = rad/100)
yaxis = curve(pos = [(0,-1.5*rad,0),(0,1.5*rad,0)], color =, radius = rad/100)
zaxis = curve(pos = [(0,0,-1.5*rad),(0,0,1.5*rad)], color =, radius = rad/200)

#label axes
text(text = 'x', pos = (1.6*rad,-rad/30,rad/50), height = rad/15, depth= -rad/25, color=color.white)
text(text = 'y', pos = (-rad/20,1.6*rad,rad/50), height = rad/10, depth= -rad/25, color=color.white)
text(text = 'z', pos = (-rad/20,-rad/20,1.6*rad), height = rad/10, depth= -rad/25, color=color.white)

#Create a list and fill it with charge carriers in random locations in the spherical region.
charges = []
for i in arange(number):
    charges.append(sphere(pos = ((randrange(-rad*100,rad*100)/(shrink*100)),(randrange(-rad*100,rad*100)/(shrink*100)),(randrange(-rad*100,rad*100)/(shrink*100))), radius = rad/33, charge = electrons*q, force = zero, velocity = zero, color =
#This list will be used to make arrows and spheres and what have you.
objects = []

#This function is used to find the distance between points, which is needed to calculate electric field. a and b are charge carriers from 'charges'.
def getDistance(a,b):
    distance = mag(charges[a].pos-charges[b].pos)
    return distance

#This function calculates net force. a = which charge is having calculations done on it. b = the charge whose field is contributing a force to a. c = distance from getDistance function.
def getNetForce(a,b,c):
    direction = charges[a].pos - charges[b].pos
    charges[a].force = (((k*charges[b].charge)/(c**2))*norm(direction))
    return charges[a].force


#This chunk updates force, velocity, and position for each charge carrier. 
for i in arange(number):
    while mag(charges[i].pos) < 2 * rad:
        for a in arange(number): #This for takes a charge carrier and compares it to...
            for b in arange(number): #... to a charge carrier in this loop.
                if a < b: #This if statement gets rid of overlap so the same calculation is not made twice.
                    distance = getDistance(a, b) #get distance between charge carriers
                    charges[a].force = getNetForce(a, b, distance) #get force on a due to b...
                    charges[b].force = getNetForce(b, a, distance) #... and on b due to a
                    charges[a].velocity = charges[a].velocity + charges[a].force #update...
                    charges[b].velocity = charges[b].velocity + charges[b].force #...velocity
                    sizeA = mag(charges[a].pos) #distance of first charge carrier from center...
                    sizeB = mag(charges[b].pos) #... and the second

                    #Charges near boundary, take two: Newtonian approach. This makes the charges "bounce off the inside of the wall by using the Rodrigues rotation formula.
                    if sizeA >= rad:
                        charges[a].pos = .999 * rad * norm(charges[a].pos) #moves charge carrier just inside sphere to avoid the charge getting "stuck"
                        posUnit = norm(charges[a].pos) #unit vector in direction of charge position
                        projection = proj(charges[a].velocity, charges[a].pos) #projection of velocity vector onto position vector
                        charges[a].velocity = -.9 *((charges[a].velocity * cos(pi)) + (cross(posUnit, charges[a].velocity) * sin(pi)) + (projection * (1 - cos(pi)))) #Rodrigues' rotation formula
                    if sizeB >= rad:
                        charges[b].pos = .999 * rad * norm(charges[b].pos) #moves charge carrier just inside sphere to avoid the charge getting "stuck"
                        posUnit = norm(charges[b].pos) #unit vector in direction of charge position
                        projection = proj(charges[b].velocity, charges[b].pos) #projection of velocity vector onto position vector
                        charges[b].velocity = -.9 *((charges[b].velocity * cos(pi)) + (cross(posUnit, charges[b].velocity) * sin(pi)) + (projection * (1 - cos(pi)))) #Rodrigues' rotation formula
    ## Clunky clode that deals with charges near boundary. Doesn't work well at all, sometimes glitchy. physics inconsistent
    ##                if sizeA > rad:
    ##                    radialDirectionA = norm(charges[a].pos)
    ##                    charges[a].pos = radialDirectionA * rad
    ##                    crossA = cross(charges[a].pos, charges[a].force)
    ##                    newForceDirA = cross(crossA, charges[a].pos)
    ##                    angleA = diff_angle(charges[a].pos,charges[a].force)
    ##                    #fixed so it doesn't get glitchy, but doesn't redistribute charges evenly on surface.
    ##                    charges[a].force = mag(charges[a].force) * sin(2 * (pi - angleA)) * norm(newForceDirA) * d
    ##                    charges[a].velocity = charges[a].force
    ##                if sizeB > rad:
    ##                    radialDirectionB = norm(charges[b].pos)
    ##                    charges[b].pos = radialDirectionB * rad
    ##                    crossB = cross(charges[a].pos, charges[a].force)
    ##                    newForceDirB = cross(crossB, charges[a].pos)
    ##                    angleB = diff_angle(charges[a].pos,charges[a].force)
    ##                    #fixed so it doesn't get glitchy, but doesn't redistribute charges evenly on surface.
    ##                    charges[b].force = mag(charges[b].force) * sin(2 * (pi - angleB)) * norm(newForceDirB) * d
    ##                    charges[b].velocity = charges[b].force

    #Optional section that displays force arrow with each update. Change it so old arrows disappear. also traces position with translucent balls.
        #for i in arange(number):
            #objects.append(arrow(pos=charges[i].pos, axis=charges[i].force, color=color.yellow)   
            #objects.append(sphere(pos=charges[i].pos, radius = rad / 33,, opacity = .1))
        for a in arange(number):
            charges[a].pos = charges[a].pos + charges[a].velocity #update position of charges...
        #print mag(charges[0].force)   
        #print mag(charges[0].velocity)

Above is a program I am writing in vpython to study geometry by simulating the electric force! Placing n like charge carriers in a hollow, neutral, insulating sphere, one would expect the to disperse among the surface of the sphere in such a way that equilibrium is reached.  My supposition was that for charge carriers > 3, equilibrium would only be reached if the number of charges corresponded to the number of vertices in a platonic polyhedral. This supposition was based on intuition and a limited understanding of geometry in 3 space.

I was pleasantly surprised. For every number of charge carriers I have tried, equilibrium is reached, sometimes in fascinating ways. My favorite is 8. Instead of forming a cube, the charges form a polyhedral with two parallel square bases, rotated such that  it has 8 other faces that are equilateral triangles. Obviously, this is the orientation that results in a net force on each charge of zero, but it also seems correct to say that the same would be true for a cube. Each vertex on a cube is the same average distance from any other vertex.

This is still a work in progress, I need to streamline it and clean it up, but it is functional. Over the next few days, I am going to do some more research into this sort of geometry and see what I can find. In the mean time, feel free to copy/paste this into the most recent version of vpython and give it a whirl! Other cool things to do would be changing the charge on one or more charge carriers. If you have any ideas or insights, let me know.

Also, this can be a general thread for fun programming adventures.

Also, lol at everything being bold from calling "b" from a list "charges[]"

*thanks parsifal

Technology & Information / American mobile network operators are terrible
« on: December 15, 2014, 02:44:16 AM »
I have ordered a new smartphone, the LG Optimus G E970. I got it for $1 with free 2 day shipping. I will be on my own plan, paying $20/month for unlimited talk/text and 300 MB of data. Fortunately for me, wifi is everywhere.

Science & Alternative Science / Holographic Universe
« on: October 21, 2014, 03:07:25 AM »

A very interesting read, in my opinion. If anybody is aware of any critisisms of the theory, please share.

TL;DR The universe is a hologram, and everything in the universe is connected at a fundamental level. Also, LSD lets us tap into other parts of reality.

Philosophy, Religion & Society / kids these days
« on: June 06, 2014, 04:25:57 AM »

Philosophy, Religion & Society / Anselm's ontological argument
« on: June 03, 2014, 03:19:54 AM »
Yackoff has referenced this quite a few times in his posts, so I decided to read up on it. My first impression upon reading it was that it was dumb...

As was the second impression, and the third, etc.

My main complaint with the argument is his concrete use of subjective words and phrases such as "greater than" or "perfect".

Specifically, at what I consider the pivotal point in his suppositions, he concludes that "something that exists both in reality and in the mind is greater than something that exists in the mind alone." Why is this the case?

Another weak spot is his premise. He makes the supposition that god is simply a being which cannot be improved upon. If that is the case, and the image of perfection is completely objective (as suggested by the argument), we should be able to determine exactly what god is, what he does, and how he does it.

It seems to me that Anselm's argument is nothing more than a flimsy, paradoxical word game with an audacious conclusion.

Technology & Information / C++
« on: January 27, 2014, 12:28:40 AM »
I am taking a C++ course this semester to become mastr haxor. I am completely new to it but I find it fairly exciting. So far, the only program we've had to write modeled Newton's simple equation:


However, I feel like it will get more complicated very soon. Can I rely on my FES brethren for help when necessary? I've looked ahead to Friday's assignment; it is to write a complete program to calculate the area of a triangle using dimensions supplied by the user. Seems simple enough.

Also, I was wondering if any of you could write a code that can read my assignments and produce the code for them? That'd be great.

Philosophy, Religion & Society / What is the best way to be happy?
« on: January 16, 2014, 02:50:35 AM »
Is it to make as much money as possible? To focus on your passions? To avoid potential conflict? To fall in love? <3

I am at a point in my life where I need to decide how I'm going to live. Whatever you guys decide, I'll totally do.

Philosophy, Religion & Society / You are selfish.
« on: January 10, 2014, 05:51:04 AM »
Every man’s reason for living, regardless of personal philosophy or religion, is to satisfy himself to the best of his abilities. Every decision he makes is for his own benefit (or perceived benefit). There are no exceptions.

The natural conclusion that follows is that true selflessness does not exist. This conclusion is true. No decision is motivated by anything greater than the motivation to maintain high personal satisfaction. For the sake of clarity in the OP I will provide counter examples.

     1.   Philanthropists – Generous people who risk life and limb to help those in need are not being selfless, per se. They are acting for themselves by helping others. Essentially, they are maintaining personal satisfaction by maintaining others. If they did not help others, they would not be satisfied. If they didn’t “feel good” about helping others, they would not do it.

     2.   Religious people – Religious people who sacrifice their belongings and time, and comply with laws that go against their biological nature are completely motivated by their own interests. They are not “doing things for god”. They are doing things so that they go to heaven. If God said “Regardless of how much you give, you will go to hell.”, there would not be a single man who resisted his natural urges, instincts, and desires.

     3.   People in love – In a situation where a mother would sacrifice her life to save her child, the mother is not necessarily being selfless. At this point I would like to introduce something I have labeled “The happiness threshold”. It could very well be called the suicide threshold, but I am an optimist. Any level of personal satisfaction above the threshold represents a desire to live and experience perception. Anything below the threshold represents a lack of desire to live; it is a desire to die. A mother who lets herself die to save her child is gambling that if she were to let her child die, she would dip below the happiness threshold and experience overall dissatisfaction. She is gambling that life would not be worth living. She is making a decision based on her own desires and satisfaction.

Feel free to offer any counter examples to my assertion that nobody is selfless.

TL;DR No man cares about another more than he cares about himself.

Technology & Information / New Chrome update question
« on: January 08, 2014, 09:44:23 PM »
Chrome has recently changed for me, noticeably the way scrolling works. When I use my trackpad to scroll, it goes in large chunks, not fluidly. Is there a way I can change this? inb4 change browsers

Arts & Entertainment / Make music!
« on: December 10, 2013, 04:13:25 AM »
I have heard Crudblud's music and a bit of Parsifal's. Is there anybody else here who likes to record? I do, but I haven't made anything I'm confident posting yet. Hopefully that changes soon.

Anyways, this thread is for the discussion of any music you have worked on or are currently working on. Post if you can, I'd love to hear!

Suggestions & Concerns / stats page
« on: December 07, 2013, 05:16:45 PM »
Is it possible to make it so the stats page only shows data from December 2013 on? I'm kind of a stats junkie and it bugs me when nearly two years of data skews averages and whatnot. It's probably not a high priority, with all the changes currently being made, but I would appreciate it if it's possible.

Also, I'm curious what happened in April 2012. There was a lot of activity that doesn't make sense.

Pages: [1]