r/Python • • Dec 01 '18

render 3d cube wireframe in console

1.2k Upvotes

39 comments sorted by

76

u/vanyakosmos Dec 01 '18

10

u/Samareye987 Dec 02 '18

Is this done with an external library?

25

u/vanyakosmos Dec 02 '18

with numpy

40

u/muntoo R_{μν} - 1/2 R g_{μν} + Λ g_{μν} = 8π T_{μν} Dec 02 '18

Most well-written code I've yet seen on this sub for these visualizations posts

...Though you could consider using quaternions just for the heck of it. :-)

9

u/oogje Dec 02 '18

It's so clean, python can be beautiful...

1

u/BaneOfFishBalls Dec 12 '18

Just for the heck of it?

I have been lurking, but this comment makes me really sad.

I Just Kant.

Stupid puns

0

u/[deleted] Dec 02 '18

[deleted]

5

u/muntoo R_{μν} - 1/2 R g_{μν} + Λ g_{μν} = 8π T_{μν} Dec 02 '18

I'm looking at purely style and structure, not algorithmic beauty.

If you've been through the source of most posts on here, they're usually hundred lines of nested ifs and weird gunk.

This one was clean and organized. Many small, short functions.

1

u/Chicken-of-Wisdom Beginner Python Programmer Dec 02 '18

Thancc

4

u/ariasaurus Dec 02 '18

speaker: Let's do this simple thing ...

audience: boo!

speaker: in the console

audience: yay!

I actually like this animation and spent about a minute staring at it. Basically 2 views.

2

u/vanyakosmos Dec 02 '18

this. I literally completed only couple of basic tutorials on 3d graphics. Don't know why so many people got excited.

1

u/billsil Dec 02 '18

Cause nobody knows about backspace and up in the terminal for one. Second would be the animation part, not necessarily the math. I'd be impressed by a multifrequency sine wave traveling; the math is even easier. Basically, it looks cool.

2

u/XNormal Dec 02 '18

Double vertical resolution by using .|’|; (and spaces for background).

Don’t use unicode for even higher resolution. Keep the old school retro charm.

2

u/vanyakosmos Dec 02 '18

why shouldn't I use unicode? it looks nice (but a bit slower)

22

u/[deleted] Dec 02 '18

Damn this is the most python thing I've ever seen. Can I just import cube yet?

54

u/konshensx Dec 01 '18

Goddamn people are just amazing . Well done

9

u/CeeMX Dec 02 '18

And it is rotating in two directions, black magic!

7

u/[deleted] Dec 01 '18

Neat

28

u/[deleted] Dec 01 '18

My weirdest fap

4

u/[deleted] Dec 02 '18

Not mine

6

u/sivadneb Dec 02 '18

Ok now make Doom

2

u/lerrigatto Dec 02 '18

So beautiful, can you pass 3d files to it?

11

u/vanyakosmos Dec 02 '18

Currently it loads hardcoded model. Maybe one day I will teach it to load from file.

1

u/alexzoin Dec 02 '18 edited Dec 02 '18

Can someone explain this to me?

If __name__ == '__main__':

    main()

2

u/vanyakosmos Dec 02 '18

if script was launched directly (python this_script.py) then run main(). if script was just imported from another script then don't run main()

1

u/alexzoin Dec 02 '18

Oh that's really cool. I haven't seen that before.

2

u/wesperax Dec 01 '18

Super nice!

2

u/Yamcha2020 Dec 02 '18

This is rad as hell!

2

u/PhroznGaming Dec 02 '18

I don't understand to the math but God damn is that code beautiful.

Tip of the hat to you my friend!

1

u/ThatsALovelyShirt Dec 02 '18

It's cool, but can you do it with a projection-based viewport rather than orthographic?

1

u/santoso-sheep Dec 02 '18

is this perspective projection or orthographic projection?

1

u/adap23 Dec 02 '18 edited Dec 04 '18

Very interesting and well written code

1

u/zoomrollerskater Dec 02 '18

Sorry guys I'm a noob here, What file to run to execute all of it?

1

u/OldSchoolBBSer Dec 02 '18

Now that's sexy. Thumbs up.

1

u/Chicken-of-Wisdom Beginner Python Programmer Dec 02 '18

This....

Is...

legendary

1

u/mikeVell Dec 02 '18

Isn’t this how the first graphics were created ?

1

u/Thalass Dec 01 '18

WITCHCRAFT

0

u/[deleted] Dec 02 '18

[deleted]

5

u/irrelevantPseudonym Dec 02 '18

And then use it to make that game boy emulator.