Advanced C++ Programming Tutorial 1 [Line Drawing / Linear Equations]

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Praise the gods! Chili posted a video exactly when I was wanting to learn something new/relearn something.

MrSpecialR
Автор

Hey, Chili! The 3rd group of people here: i barely know anything about linear algebra, but i really loved this video and learning the topic with you.

avtem
Автор

Respect from China, very very good video, I can learn both english listening and programming, thank you sir.

MrNick
Автор

For some unknown reason I am very stingy with my subscriptions... This is the first video I watched from this channel and immediately gave mine :D

zyfryth
Автор

I just realized I never really understood what the m and b mean, thx for the clear explanation.

haos
Автор

Thanks Chili. I found this awesome series few days ago and it's very helpful. This is a treasure really Thank you again ❤

TenderBug
Автор

in german highschool we've learned it with f(x) = mx + n... good to hear about other countrys and their math ;)

chinaman
Автор

if I hadn't gone through two run-throughs of the beginner series I'd never be able to grapple with this

rob-fb
Автор

awesome!I think I'm gonna fall in love with math and canada again!

chilinouillesdepommesdeter
Автор

@22:18, you need to change definition and declaration of Mouse.h and Mouse.cpp from std::pair<int, int> GetPos() const; to Vei2 GetPos() const; or else you will get error

Ravikiran
Автор

28:20 a "better" way to get the inverse of m would be to (1.0f / m), you might have not mentionned it because it's harder to understand but tought i would point it out anyways

Malik-lotw
Автор

Chilli. Use shift in photoshop to draw straight lines. Click then hold shift. With second click you connect those two points . Thanks for tut.

romanemul
Автор

Man, the most important thing to draw for me is the libraries at the start of the line, and the other maths are so simple, but i cannot understand how you can draw with c++.

adrianelpiola
Автор

In Poland we use a instead of m so it looks like y = ax + b, we also learn that in high school. 'm' is reserved as a 'parameter'.

adamkangoroo
Автор

11:06 What Library did you use to work with Graphics?

Phroton
Автор

freaking hell! C++ is really a tough one to master

gotyamaywritedat
Автор

I was going to ask if switching slope dominance when x and y are equal (eg the line y=x) would be easier, then I realized you swapped dominance when the slope is 1, which is the same thing.... and easier. Great tutorial Chili, looking forward to the next ones!

ixamraxi
Автор

There's a bug with drawing a line, if you make p0 and p1 the same point you'll get an assert x>=0

demagoguely
Автор

A bit of confusion, if we use delete on an object pointer, it deletes the memory allocated in heap for that object and then what happens to the pointer, does it still points to the same memory.
What if we use delete on a normal pointer ( like int* n or char* c );
It's kind of dumb to ask but it's a bit confusing, what does delete do.
And what is the diff between copy const. and copy assign: Is it that they both do same thing but assign lets us assign one object to another using = and return a pointer of object type( just want to be clear to myself);

rajul
Автор

Hello Chili! I tried to write a (maybe) simpler algorithm for line drawing. Didn't see anyone use something similar, maybe because is not so efficient. It's straightforward parametric plot:

float t;
int x, y;

int dx = x2 - x1;
int dy = y2 - y1;

int nPixels = std::max(abs(dx), abs(dy));

for (int i = 0; i <= nPixels; i++)
{
t = (float)i / nPixels;
x = x1 + t * (x2 - x1);
y = y1 + t * (y2 - y1);
PutPixel(x+0.5, y+0.5, c);
}

[I omitted castings for better readability]

and it works fine, in any situation, no need to check for reciprocal position of the points. Of course if the two points coincide you divide by zero, but you get the point (LOL). This way you can plot anything, circles, parabolas, lissajous, etc.
I tried also the Bresenham's algorithm and I get different results cause casting truncation. So I added 0.5f before the (int) casting on PutPixel and I get the exact same results as the B. algorithm. I'm very pleased with that!
I also made some speed testing. My algorithm is 2 x slower than Bresenham's one :D

mjthebest
visit shbcf.ru