This week was really well for me. Because I've reached some of my weekly goals!
- Reach 80 followers on Twitter. ✅
- Reach 500 subscriber on Youtube ✅
- Reach 280 followers on Instagram. ✅
I know! I know, it's not big numbers. But it's a progress and I'm proud of myself 🥳
What I've learned previous week?
How to determine if a point lay on the line or not?
I was working on a project at Swiftmade. I had needed to determine if a point is on the line or not. I've realized that my math was not enough to do this quickly 😬😊😂. I've found a couple of solutions to implement but this one was working really good.
isOnLine(line, point) {
// a: first point of line
// b: end point of line
// c: target point
const ab = Math.sqrt(
(line[0][0] - line[1][0]) ** 2 + (line[0][1] - line[1][1]) ** 2
)
const ac = Math.sqrt(
(line[0][0] - point[0]) ** 2 + (line[0][1] - point[1]) ** 2
)
const bc = Math.sqrt(
(line[1][0] - point[0]) ** 2 + (line[1][1] - point[1]) ** 2
)
// const result = Math.abs(ac + bc - ab) < Number.EPSILON
const epsilon = 0.005
const result = ac + bc - ab < epsilon
return result
}
Number.EPSILON
did not work well in my case. Using 0.005
was working well instead.
What did I do during previous week?
Remember user preference of dark mode on my website
When you choose dark mode or light mode on this website, it will remember that and will works according to your last choice. 🥳
A new youtube tutorial
I've published the third episode of twitter clone tutorial.
Links
- https://brilliant.org - Courses about math, programming and science
- https://edit.photo - Free photo editor on the browser
- https://blog.ugursogukpinar.com/internet-nedir-ve-nasil-calisir
- https://dangitgit.com/en - Cheet sheet for git
- https://tally.so - free service to create forms