Join us on Discord!
You can help CodeWalrus stay online by donating here.
Menu

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.

Show posts Menu

Messages - Thecoder1998

#1
hi guys, i made a vectory library in python :)
i'm looking for some more things to implement, maybe you guys could come up with some ideas

from numpy import matrix, arctan, arccos, sqrt
def vec(a, b, c = None, d = None):
    if c == None and d == None:
        return matrix('%s;%s' % (a, b))
    elif c != None and d == None:
        return matrix('%s;%s;%s' % (a, b, c))
    else:
        return matrix('%s;%s;%s;%s' % (a, b, c, d))
def dim(v):
    return v.shape[0]
def comp(v, a):
    return v.item(a - 1, 0)
def dot(v1, v2):
    if dim(v1) == dim(v2):
        dot = 0
        for i in range (dim(v1)):
            dot = dot + comp(v1, i) * comp(v2, i)
        return dot
    else:
        return "error"
def cross(v1, v2):
    if dim(v1) == 3 and dim(v2) == dim(v1):
        u1 = comp(v1, 1)
        u2 = comp(v1, 2)
        u3 = comp(v1, 3)
        w1 = comp(v2, 1)
        w2 = comp(v2, 2)
        w3 = comp(v2, 3)
        n1 = u2 * w3 - u3 * w2
        n2 = u3 * w1 - u1 * w3
        n3 = u1 * w2 - u2 * w1
        return vec(n1, n2, n3)
    else:
        return "error"
def stp(v1, v2, v3):
    if dim(v1) == dim(v2) and dim(v2) == dim(v3):
        return dot(v1, cross(v2, v3))
    else:
        return "error"
def vtp(v1, v2, v3):
    if dim(v1) == dim(v2) and dim(v2) == dim(v3):
        return cross(v1, cross(v2, v3))
    else:
        return "error"
def length(v):
    return sqrt(dot(v, v))
def angle(v1, v2):
    if dim(v1) == dim(v2):
        return arccos(dot(v1, v2) / (length(v1) * length(v2)))
    else:
        return "error"
def printv(v):
    if v != "error":
        if dim(v) == 2:
            a = comp(v, 1)
            b = comp(v, 2)
            vec = '(%s, %s)' % (a, b)
        if dim(v) == 3:
            a = comp(v, 1)
            b = comp(v, 2)
            c = comp(v, 3)
            vec = '(%s, %s, %s)' % (a, b, c)
        if dim(v) == 4:
            a = comp(v, 1)
            b = comp(v, 2)
            c = comp(v, 3)
            d = comp(v, 4)
            vec = '(%s, %s, %s, %s)' % (a, b, c, d)
        print vec
    else:
        print "error"
def printpol(v):
    if v != "error":
        if dim(v) == 2:
            x = comp(v, 1)
            y = comp(v, 2)
            r = length(v)
            theta = arctan(y / x)
            vec = matrix('%s;%s' % (r, theta))
        elif dim(v) == 3:
            x = comp(v, 1)
            y = comp(v, 2)
            z = comp(v, 3)
            r = length(v)
            theta = arctan(y / x)
            phi = arccos(z / r)
            vec = matrix('%s;%s;%s' % (r, theta, phi))
        printv(vec)
    else:
        print "error"

EDIT: Added the .py file so people can be lazy
#2
Hi guys, i'm currently learning how to program in Python and i've made a neat little script which can do arithmetic with quaternions  :)

from numpy import matrix
def quaternion(a,b,c,d):
    u = matrix('1.,0.,0.,0.;0.,1.,0.,0.;0.,0.,1.,0.;0.,0.,0.,1.')
    i = matrix('0.,1.,0.,0.;-1.,0.,0.,0.;0.,0.,0.,-1.;0.,0.,1.,0.')
    j = matrix('0.,0.,1.,0.;0.,0.,0.,1.;-1.,0.,0.,0.;0.,-1.,0.,0.')
    k = matrix('0.,0.,0.,1.;0.,0.,-1.,0.;0.,1.,0.,0.;-1.,0.,0.,0.')
    q = a*u+b*i+c*j+d*k
    return q
def printquaternion(q):
    a = q.item(0,0)
    b = q.item(0,1)
    c = q.item(0,2)
    d = q.item(0,3)
    q = "%s+%si+%sj+%sk"%(a,b,c,d)
    print q

here is a screenshot

#4
I recently got Steins;Gate the visual novel and Jazzpunk
I absolutely LOOOVE Steins;Gate
#5
Quote from: alexgt on March 27, 2015, 01:44:40 AM
Anyways my question is about zStart. I put zStart on my calc and it didn't work :(. Do you need a OS lower than 2.55MP because that is what I have? And also is the latest version 1.3.013?
Thanks for the help :).
Iirc, you don't need an OS lower than OS 2.55MP, but i know for sure that zStart will be more stable on OS 2.43
Did you even enable zStart on your calc?
#6
hey this looks pretty awesome :)
#7
Media Talk / Re: What series do you watch?
January 30, 2015, 08:53:10 PM
Atm i'm watching:

Anime:
Kill la Kill (almost done)
Aldnoah.zero season 2

Cartoons:
Adventure time (i'm at season 3 atm)
Steven universe
Gravity falls (still waiting for new episodes q.q)

Other Series:
The Blacklist (great series)
#8
Media Talk / Re: Funny/awesome Youtube videos
January 30, 2015, 08:49:13 PM
Quote from: Cumred_Snektron on January 30, 2015, 07:26:09 PM
I see you see i like mowtendoo.
But wait did you see that?
I see juju sees cumred sees juju sees cumred likes mowtendoo.
#9
I love japanese people, being better at everything we do.
Quote from: Cumred_Snektron on January 30, 2015, 08:40:43 PM
Sanic

Approves
XD
#10
So during computer science class we're doing information modeling
And we decided to use codewalrus for our diagram

Pretty cool eh?
#11
Drawing & Animation / Re: Walrii fanart
January 13, 2015, 06:13:56 PM
for the record, i'm back and i'll try to make time to be more active on cw
unfortunately, my french teacher thinks we don't have a life and gives us craploads of homework :(
and i like watching anime a lot, so that's why i'm not really coding something lately
EDIT: when i first joined omnimaga, i was active a lot, but nowadays i don't really have anything useful to post, unlike cumred snektron (i love that name)
#12
Nice work!
#13
Looking pretty awesome, cumred!
#14
Other / Re: New member introductions: Say hello here!
January 08, 2015, 02:03:47 PM
Hello, I'm Thecoder1998
My hobbies are coding, watching anime, gaming and doing other random shloop on my pc.
Nice to meet all of you! (although i already know like 90% of you  :P)

oh and i don't actually have internet on my pc right now, so i'm not posting a lot (i'm writing this on a pc at school)
#15
that song is even more epic than the avicii remix xD
Powered by EzPortal