Better HN
topnewbestaskshowjobs
Log inSign up

EternalCarnage

3 karma · joined Jun 23, 2023 (3y ago) · 6 submissions

carnage.skopl@aleeas.com
Submissions

1.

Test driven development and ADHD (2021)(80hd.dev ↗)

6 points · by EternalCarnage · 3y ago · 1 comment

comment 3y ago · link · parent

Learning with examples is crucial. Personally, I find it easier to grasp mathematical concepts when I encounter them in various real-life scenarios. Similarly, understanding the rationale behind the introduction of a specific concept or definition in a field helps me comprehend it better.

To me, mathematics is a carefully crafted compilation of concepts devised to provide precise descriptions (like cross product, dot product, determinants, derivatives) or simplify and generalize ideas (such as linear maps, wedge product).

In essence, mathematicians create these tools and then analyze them to uncover similarities and patterns.

Would math "exist", if there were no "sensory inputs" at all?

comment 3y ago · link · parent

The problem of having a "secret" computer (with an operating system) within your computer.

https://youtu.be/1seNMSamtxM

This embedded computer system has access to all your memory devices.

Disabling it? Not convenient.

4.

Tell HN: Essence of Rendering

1 points · by EternalCarnage · 3y ago · discuss

comment 3y ago · link · parent

Getting the signal from the noise - A demonstration attempt (inspired by @laurieg's comment):

Rendering: how to turn a virtual 3D scene into a (2D) image? Answer: (affine and perspective) geometry, usually in the form of vectors and points and some physics. (Matrices, multivectors, are structures for convenience.)

The core concepts you need are:

1. Perspective projection (perspective geometry):

X* = H * (X / Z)

Y* = H * (Y / Z)

2. Coordinate mapping (affine geometry):

MapRange(Value, Source, Target) := Value' = Scale * (Value - Source.Min) + Target.Min

Scale := (Target.Max - Target.Min) / (Source.Max - Source.Min)

Where Source is your "old" 2D coordinate system interval (e.g., [-1; 1] x [-1; 1]) and Target is your new coordinate system interval (e.g., [0; Width] x [0; Height]).

Although, we usually have to deal with flipped y-coordinates, so:

[0; Width] x [Height; 0] or for rasterization:

X' = MapRange(X, Source=(-1, 1), Target=(0, Width))

Y' = MapRange(X, Source=(-1, 1), Target=(Height, 0))

... and ray tracing:

X' = MapRange(X, Source=(0, Width), Target=(-1, 1))

Y' = MapRange(Y, Source=(Height, 0), Target=(-1, 1))

3. Containment (affine; rasterization):

w := (1 - u - v), A, B, C from R2.

OP = uAB + vAC + OA <=> AP = uAB + vAC <=> OP = uOB + vOC + (1 - u - v)OA <=> P = uB + vC + (1 - u - v)A = uB + vC + wA

If you solve AP = u

AB + vAC for u and v via Cramer's rule or by hand, you may get:

A := Det(AB, AC)

u := Det(AB, AP) / A

v := Det(BC, BP) / A

w := 1 - u - v = Det(CA, CP) / A

P is inside triangle ABC, if u, v, w >= 0 and u + v + w = 1.

4. Intersection + Containment (affine):

<.,.> - the dot product.

t = <PlanePoint - RayOrigin, PlaneNormal> / <RayDirection, PlaneNormal>

If t > 0, the line or ray intersects with the triangle's plane.

X = Ray(t) = RayOrigin + t

RayDirection

Now, you can reuse the 2D point containment check (3), to see whether the ray intersects also the triangle (lying on that plane).

---

Filtering the "noise" (overhead/information overload), getting to the "gist", for me, is not easy, but you can get there, if you care enough.

comment 3y ago · link · parent

History.

You do what your operating system vendor does.

Not few operating systems have a C interface. The implementation of binaries (see also application binary interfaces) depends on the operating system.

Shared libraries (e.g., DLL) are binaries, too.

C compiler developers have the ability to generate consistent[1] binary outputs.

In simpler terms, vendors of these compilers can reach a consensus on how to convert C code into binary files, known as Application Binary Interfaces (ABI).

It is not uncommon[2] to have a foreign function interface in C.

1. http://yosefk.com/c++fqa/defective.html

2. https://learn.microsoft.com/en-us/cpp/dotnet/calling-native-...