Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
hobbesmaster
Jan 28, 2008

you can use quarternions if you really want :V

also what are you using to write it? many frameworks have convenience functions built in to modify rotation matrices by an angle or displacement or looking at a point etc

example from qt http://doc.qt.io/qt-4.8/qmatrix4x4.html

Adbot
ADBOT LOVES YOU

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Luigi Thirty posted:

i rewrote it to not use matrix math because i was just copy/pasting poo poo off the internet that i didn't understand lol

you're better off in the long run learning the matrix math. there's a reason it's ubiquitous. plus learning math builds character.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

fleshweasel posted:

actually yeah if you give developers a notion like visual studio solutions they're inevitably going to use it to mash hundreds of projects together without regard for which ones have anything to do with each other and which ones are really necessary to load in order to do the thing you're working on. just open up AllMyCompanysShit.sln

yeah we have a shitload of specific solutions that you can actually open and debug and then one god solution for when you need to find some 10 year old code that everything depends on for reasons

i wish it weren't so bad because it's basically soured my entire company on .net

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

HappyHippo posted:

you're better off in the long run learning the matrix math. there's a reason it's ubiquitous. plus learning math builds character.

yeah, if you're doing any computer graphics stuff matrices are kind of the building blocks of everything, so it's well worth being familiar with basic linear algebra. they're also necessary if you ever end up implementing any fancy animation stuff

think of it as learning a framework, except that that framework happens to be math that lets you specify the location and orientation of things in space

Luigi Thirty
Apr 30, 2006

Emergency confection port.

the gray forum said not to use matrices in your first homemade renderer!!

Bloody
Mar 3, 2013

why not matrices are good

Luigi Thirty
Apr 30, 2006

Emergency confection port.

so you're not trying to do every operation in one step when you don't understand the underlying math i guess

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
well the important thing is to learn what the matrices are doing and how they do it, instead of treating them as a black box.

looks like the gray forum was talking about the projection matrix. you need to learn how the projection works and then how the projection matrix accomplishes it.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

oh my god i have autism :doh: (ignore the borked field of view)

code:
            if(key == 'e'){
                cameraRotation.y -= 5;
            }
            else if(key == 'q'){
                cameraRotation.y += 5;
            }
code:
        //Translate
        //apply world translation
        screenCoords[i] = Vector3f(screenCoords[i].x - eye.x,
                                   screenCoords[i].y - eye.y,
                                   screenCoords[i].z - eye.z);

        //then apply local translation
        screenCoords[i] = Vector3f(screenCoords[i].x + model.translation.x,
                                   screenCoords[i].y + model.translation.y,
                                   screenCoords[i].z + model.translation.z);

        //then apply camera rotation
        screenCoords[i] = rotateAroundXAxis(screenCoords[i], cameraRotation.x);
        screenCoords[i] = rotateAroundYAxis(screenCoords[i], cameraRotation.y);

comedyblissoption
Mar 15, 2006

tef posted:

i mean pay-as-you-go works out in your favor when you don't use a feature, but when 90% of you code does maybe that whole "no-gc" thing doesn't work out
"no-gc" may not inherently mean c++-like frankenstein complexity. rustlang may turn out to be such an example.

rustlang's ownership type system is powerful and usefully eliminates a class of errors that I suffer in C# on a regular basis. rustlang statically eliminates concurrent data races on writable, shared memory. rustlang statically eliminates mutable aliasing of data as the default. ownership and language defaults heavily encourage a style of programming that avoids pervasive, mutable state.

rustlang's ownership model relies heavily on scopes. when you force your type system to be so intrinsically linked to scopes, a GC may not actually buy you much in reducing the complexity of the language. from what i've read, rustlang initially planned to incorporate a GC, but the ownership system changed their perspective to such a degree that such plans were scrapped from the initial release of the language

the ownership system models explicitly what is usually done implicitly to try to simplify problems. violating this model greatly increases the complexity of a program and the chance for error.

a gc-lang without an ownership model may very well be less productive than a no gc-lang with an ownership model. if this is true, then the whole "no-gc" thing might be good enough.

keep in mind that i do agree a GC simplifies programming and would simplify it even with an ownership system.

Sapozhnik
Jan 2, 2005

Nap Ghost
Homogeneous co-ordinates are also a thing to look into.

You have a point in a 4D co-ordinate space (x, y, z, w) which maps to the 3D point (x/w, y/w, z/w). This allows you to do perspective foreshortening and affine transformations (i.e. a combination of a scale and an offset, something you can use to move things around as well as scaling/spinning/shearing/whatever them around their center) using a single 4x4 matrix. You can't normally do this with 3x3 matrices because they are basically a generic shorthand for linear functions of vectors, and you can't make a linear function that moves things around because it will necessarily need to map zero to something other than zero.

But you can cheat by having a fake zero point at (0,0,0,1) which then becomes (0/1, 0/1, 0/1) = (0,0,0) in the final dehomogenization(?) step. I'm not too knowledgeable on the actual math behind it but homogeneous co-ordinates are a sort of mathematical hack to make affine transformations linear.

Then there's quaternions, which are basically a completely different way of doing rotations but idk how they apply to other kinds of transforms. Quaternions are useful because you can smoothly blend between two rotations expressed as quaternions whereas you can't really do that with matrices anywhere near as easily. But actually applying them to a 3-vector using a Hamilton product requires slightly more arithmetic operations then the equivalent multiplication by a 3x3 matrix

(disclaimer: it's been a long time since I looked into this stuff so I may well be talking complete poo poo)

Bloody
Mar 3, 2013

why do people call it rustlang when the name is rust

comedyblissoption
Mar 15, 2006

you dont want to get it confused with the fungi

Valeyard
Mar 30, 2012


Grimey Drawer

Bloody posted:

why do people call it rustlang when the name is rust

the same reason people call Go Golang

because Rust (and Go) are too generic words and really bad names

Bloody
Mar 3, 2013

rust isnt used for anything else in programming or computering though

Bloody
Mar 3, 2013

like if you're mashing out paragraphs of text about the language named rust it's gonna be pretty obvious you're talking about the language rust

tef
May 30, 2004

-> some l-system crap ->

comedyblissoption posted:

"no-gc" may not inherently mean c++-like frankenstein complexity. rustlang may turn out to be such an example.

*sprinkle some std::sync::Arc, and we're done*

quote:

rustlang's ownership type system is powerful and usefully eliminates a class of errors that I suffer in C# on a regular basis. rustlang statically eliminates concurrent data races on writable, shared memory.

i'll take "if more than 50% of your code is mutable shared state you're going to have a bad time" for $500, alex

quote:

rustlang statically eliminates mutable aliasing of data as the default. ownership and language defaults heavily encourage a style of programming that avoids pervasive, mutable state.


like the point of a transaction is to preserve invariants, but also to allow you to locally subvert them and isolate the partial changes from the rest of the system.with rust, well, you must always preserve the invariant. you can't locally subvert it within a function call

and then you end up with the std::replace head-swapping to work around it.

quote:

keep in mind that i do agree a GC simplifies programming and would simplify it even with an ownership system.

yeah it's just that tbh ref-counting regions is pretty good, and every big-rear end system ends up with an arena based allocator anyhow.

i suspect you'd be better off with a very coarse grain ownership model across scopes/regions than entries inside of it.



i dunno rust's ownership model has a very "checked exceptions" feel to it, something that makes your program stable in the short term but fragile to change in the long term

i'm glad rust is experimenting with it but I haven't really been tempted to experiment in rust despite watching it since ~0.3

tef
May 30, 2004

-> some l-system crap ->

Bloody posted:

why do people call it rustlang when the name is rust

seo mate

Valeyard
Mar 30, 2012


Grimey Drawer

Bloody posted:

like if you're mashing out paragraphs of text about the language named rust it's gonna be pretty obvious you're talking about the language rust

yeah but think about searching

"help with rust" - obviously no results about the language

"how to get started with rust" - too many results about the game called Rust

tef
May 30, 2004

-> some l-system crap ->

tef posted:

seo mate
gotta think about ur twitter account, github repo, and domain mate

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Valeyard posted:

yeah but think about searching

"help with rust" - obviously no results about the language

"how to get started with rust" - too many results about the game called Rust

yeah its this.

triple sulk
Sep 17, 2014



we should go back to naming languages things like cobol/fortran/delphi/prolog

Sapozhnik
Jan 2, 2005

Nap Ghost

mutability and ownership are completely orthogonal

doing some embedded C at the moment and most of my pain points at the moment are making sure i can roll things back and deallocate at every single point where something might fail. not a fun time.

arguably exceptions and try-with-resources blocks actually make code harder to understand compared to a bunch of gotos into a sequence of rollback operations.

hobbesmaster
Jan 28, 2008

Mr Dog posted:

mutability and ownership are completely orthogonal

doing some embedded C at the moment and most of my pain points at the moment are making sure i can roll things back and deallocate at every single point where something might fail. not a fun time.

arguably exceptions and try-with-resources blocks actually make code harder to understand compared to a bunch of gotos into a sequence of rollback operations.

they should be equivalent.

have you implemented something like this? http://www.drdobbs.com/exception-handling-in-embedded-c-program/184401349

you're still using exceptions, you're just rolling your own with gotos

Bloody
Mar 3, 2013

Mr Dog posted:

mutability and ownership are completely orthogonal

doing some embedded C at the moment and most of my pain points at the moment are making sure i can roll things back and deallocate at every single point where something might fail. not a fun time.

arguably exceptions and try-with-resources blocks actually make code harder to understand compared to a bunch of gotos into a sequence of rollback operations.

if you're doing dynamic allocation in embedded I feel bad for you son

VikingofRock
Aug 24, 2008




eschaton posted:

passing collections is perfectly natural

just don't suggest he should be passing iterators around, that's awful and something that people who actually understand OO should have corrected Stepanov and Stroustrup on as soon as they started talking about it

I disagree. Iterators make your code more flexible, easier to refactor, and the issues with invalidation aren't really worse than anything else in C++.

Sapozhnik
Jan 2, 2005

Nap Ghost

Bloody posted:

if you're doing dynamic allocation in embedded I feel bad for you son

embedded-ish, this particular thing runs Linux because it needs to do HTTPS amongst other things.

I'm prototyping on a Raspberry Pi but it's potentially going to scale down pretty hard from there.

Sapozhnik
Jan 2, 2005

Nap Ghost

VikingofRock posted:

I disagree. Iterators make your code more flexible, easier to refactor, and the issues with invalidation aren't really worse than anything else in C++.

If you're defining a function that can take an arbitrary class of iterator as a parameter then that function needs to be a template and you're going to bloat the hell out of your code with all of its different instantiations. Plus your compile time will continue to take a poo poo.

If that's not something you care about then why are you using C++, use Java or Python or something.

comedyblissoption
Mar 15, 2006

tef posted:

*sprinkle some std::sync::Arc, and we're done*
Arc<T> isn't a good example of rust being as complex as C++, because java and C# and basically every other language w/ multi-threaded concurrency has implicit forms of Arc<T>. Arc<T> and its implicit forms are just inherently complicated. rust at least simplifies the problem by statically guaranteeing you didn't accidentally introduce a data race around the data that should be locked (unlike C#). rust has other stdlib concurrency mechanisms like channels that are simpler for most problems.

rust is complicated, but i feel it's not because it's introducing accidental complexity. i feel like it's around the level of something like C#. rust could be simpler if it used a GC, but i think for me it might end up being more productive than chasing all these loving bugs i'm dealing w/ in a gc-lang like C# on a routine basis.

quote:

i dunno rust's ownership model has a very "checked exceptions" feel to it, something that makes your program stable in the short term but fragile to change in the long term
hopefully i'm able to play around with rust long enough to see. you might be right and the very strict ownership model turns out to be a terrible mistake. checked exceptions sounded like a good idea at the time but now most people think it was a terrible idea. it's probably true though that the strictness of rustlang's ownership model is necessary to make the guarantees it does though.

comedyblissoption
Mar 15, 2006

if you're fine with passing around IEnumerable in C# around to functions, you should be fine with passing iterators around in c++ or rust

you need to pass IEnumerable or iterators around to functions in order to extend the functionality of these iterators in the first place (e.g. implementing Zip)

it's a bit more problematic in c++ though because everything shits itself and maybe you get security holes when you invalidate an iterator in c++

in C#, the system can at least throw an exception and you don't get memory unsafety

in rust, you are statically guaranteed not to invalidate an iterator (assuming the iterator was implemented properly)

in any non-trivial codebase in a language that is not rust, it may be very difficult to guarantee you aren't potentially invalidating an iterator/IEnumerable

cinci zoo sniper
Mar 15, 2013




hobbesmaster posted:

you can use quarternions if you really want :V

also what are you using to write it? many frameworks have convenience functions built in to modify rotation matrices by an angle or displacement or looking at a point etc

example from qt http://doc.qt.io/qt-4.8/qmatrix4x4.html
quaternions are not a great idea for person who doesnt feel comfortable with matrices. ive heard that they alleviate some of the headaches for coding in 3d, but the math there is archaic and overly complex on the whole, which is why you don't really see non-computer people go into them without solid mathematical background.

really, i'd just go through bunch of khan academy or whatever matrix stuff, and then work poo poo up from there

cinci zoo sniper fucked around with this message at 21:18 on Jul 10, 2016

Progressive JPEG
Feb 19, 2003

tef posted:

brb importing from half of github in an ad-hoc nonrepeatable manor to maybe build a project

because of a bad design decision that only benefits googlers

i enjoy writing go (so far) but yeah that part is total bullshit

repos containing 5% your code, 95% vendored libraries

cinci zoo sniper
Mar 15, 2013




Luigi Thirty posted:

the gray forum said not to use matrices in your first homemade renderer!!
gray forum is elbows deep in their own rear end, you dont do quaternions if you dont know basic stem college math

cinci zoo sniper
Mar 15, 2013




Bloody posted:

rust isnt used for anything else in programming or computering though
yeah it just relates to metallic stuff and people past some reference time

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I barely passed stem college math :(

I was able to hook up scene rotation and rotating my direction vectors for camera movement with Euler angles which is suboptimal but okay for right now :toot:

WASD for translation, QERV for rotation

netcat
Apr 29, 2008

kalstrams posted:

gray forum is elbows deep in their own rear end, you dont do quaternions if you dont know basic stem college math

no one mentioned quats, the idea was to learn how 3d projection actually works before throwing a magical matrix at it. also no one who uses quats in 3d graphics knows the theory behind them anyway.

cinci zoo sniper
Mar 15, 2013




netcat posted:

no one mentioned quats, the idea was to learn how 3d projection actually works before throwing a magical matrix at it. also no one who uses quats in 3d graphics knows the theory behind them anyway.
oh that for sure. my angle here was that even just using them won't be miracle cure for partial familiarity with matrix algebra

oh no blimp issue
Feb 23, 2011

who cares why they work they just do

Deep Dish Fuckfest
Sep 6, 2006

Advanced
Computer Touching


Toilet Rascal

kalstrams posted:

quaternions are not a great idea for person who doesnt feel comfortable with matrices. ive heard that they alleviate some of the headaches for coding in 3d, but the math there is archaic and overly complex on the whole, which is why you don't really non-computer people go into them without solid mathematical background.

one of the (few) nice things about quaternions is also that they take less space than rotation matrices: 4 floats instead of 16. that might not seem like a huge deal, but when you have a shitload of them and performance is an issue, it can make a pretty big difference due to one representation fitting in your cache when the other doesn't. it's part of the reason why animation code in games is one of the places where you'll find quaternions

Adbot
ADBOT LOVES YOU

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Progressive JPEG posted:

i enjoy writing go (so far) but yeah that part is total bullshit

repos containing 5% your code, 95% vendored libraries

it is absolutely the worst part of go

  • Locked thread