Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
26 votes

Get vector length with GLM

Sorry folks for posting such a trivial issue! The issue is solved. I was using the wrong function. Here goes the correct one: ...
sajis997's user avatar
  • 1,279
9 votes

What is the difference between a point transformation and a vector transformation?

Here's the simple answer. In 4D, to be able to multiply them by a 4x4 matrix, vectors are represented as (x,y,z,0) and points are represented as (x,y,z,1). Since the 4th row of a 4x4 matrix ...
Alan Wolfe's user avatar
  • 7,801
4 votes
Accepted

Calculating the angle between two polygons

I suggest computing the normal vector for each polygon and compute the angle between the normal vector of one triangle and the normal vector of a plane perpendicular to the other surface that passes ...
Wyck's user avatar
  • 410
4 votes
Accepted

Video-games; Rendering textures on scope zoom-in. Texture compression problem?

Well there's no way to know for sure unless you look at the source code but my guess is that they do zooming by lowering the FOV (field of view) of the camera. This is easy to implement and actually ...
Chuck's user avatar
  • 296
4 votes
Accepted

Normal vector in Phong Illumination Model should be normalized?

Short answer: yes. Longer answer: yes, because the vectors you’re using are meant to represent directions, not directions-and-distances. Think of it in terms of light: it doesn’t matter how far a ...
Noah Witherspoon's user avatar
3 votes

Creating vector shapes using only C++

What you are looking for is a way to get access to individual pixels in an image, in a way that you can modify those pixels with CPU code. Once you have that you'll want to find software rendering / ...
Alan Wolfe's user avatar
  • 7,801
3 votes
Accepted

Vector Math for Raytracer

I think there might be a misprinting in the book. I am getting this $((A-C) + tB)\cdot((A-C) + tB) = R\cdot R$ Let A-C = Y $(Y + tB)\cdot(Y + tB) = R\cdot R$ $...
gallickgunner's user avatar
3 votes
Accepted

Perlin Noise with Smooth function vs Lerp

It looks like the way you're using smoothstep isn't quite right. With lerp, the first two parameters are the endpoints of the output range, and the third is a 0–1 value specifying how far to ...
Nathan Reed's user avatar
3 votes

Can somebody explain this Ray Tracing Function?

Good answer above. (I like that the book adds in p then subtracts it.) This is a hard-coded grey world as a "hello world" kind of ray tracer. The 0.5 is the hard-coded reflectance. Keep ...
Peter Shirley's user avatar
2 votes
Accepted

Can somebody explain this Ray Tracing Function?

vec3 target = rec.p + rec.normal + random_in_unit_sphere(); return 0.5*color(ray(rec.p, target-rec.p), world); this is the exact same as ...
ratchet freak's user avatar
2 votes

Where should I project a polygon corner when it is behind me?

Trying to explain a problem seems to help the thought process. This is what eventually worked for me: I realized that I can easily find the point (in 3D space) where a line between two of the corners ...
SE - stop firing the good guys's user avatar
2 votes

What is the difference between a point transformation and a vector transformation?

If you would look up the definition of a vector and a point, then a vector is: A quantity, such as velocity, completely specified by a magnitude and a direction. http://www.thefreedictionary.com/...
bram0101's user avatar
  • 1,605
2 votes
Accepted

Refraction: given an incoming and transmitted direction, can I deduce the normal?

See equation (16) in Microfacet Models for Refraction through Rough Surfaces : $-(\eta_i w_i + \eta_o w_o)$ which you'll probably want to normalize. $\eta$ are the two indices of refraction and $w$ ...
Olivier's user avatar
  • 1,585
2 votes
Accepted

Finding the normals of a tileable 2D surface extracted from 4D space

Since the question was somewhat clarified I will formalize both the question and the answer for future readers. Having a differentiable scalar field $f : \mathbb{R}^4 \rightarrow \mathbb{R}$ we want ...
lightxbulb's user avatar
  • 2,226
2 votes

Help understanding tangent from dot product and max distance from component wise vector multiplication

There is very little geometrical meaning to the multiplication of two vectors and there are no well defined identities describing the result. But that doesn't make it illegal, and is an important part ...
pmw1234's user avatar
  • 3,219
2 votes
Accepted

Plotting points along a 3D line segment

You shouldn’t need to use any trigonometry here at all. If you get the vector from v1 to v2 and divide it by the number of points you want along the line, each subsequent point is v1 + (that vector) × ...
Noah Witherspoon's user avatar
2 votes
Accepted

Trouble transforming vectors from view space to screen space using a perspective projection matrix

The way to do the projection is the following: ...
Thomas's user avatar
  • 1,265
1 vote
Accepted

Split a string of line segments into several other line segments

Here is some pseudo-code for an arc-length parametrization (would work for any dimension if you replace vec2 with vecD): ...
lightxbulb's user avatar
  • 2,226
1 vote

Extending an orthogonal set of vectors (graphics application?)

The most common use is almost certainly computing normal vectors for a surface, using a cross product. Although strictly speaking, this does not quite qualify as the two initial vectors are usually ...
Olivier's user avatar
  • 1,585
1 vote

3d Math Primer book equation derivation - Projecting One vector onto another

Since we have: $$\pmb{v}_{\parallel} \parallel \pmb{n},$$ then: $$\pmb{v}_{\parallel} = k\pmb{n}$$ We want that the length of $\pmb{v}_{\parallel}$ is $\|\pmb{v}_{\parallel}\|$, then: $$\|\pmb{v}...
lightxbulb's user avatar
  • 2,226
1 vote
Accepted

3d Math Primer book equation derivation - Projecting One vector onto another

Since v∥ is parallel to n, it can be expressed as some multiple of n. The multiple is the ...
Noah Witherspoon's user avatar
1 vote

How do I derive this transformation

I'm not going to dive into much details about affine transformations and such, you are better off reading up on these concepts from good graphics books. I think The matrix you need is this. $\begin{...
gallickgunner's user avatar
1 vote

Rotation of a random unit vector at a point in 3D space by an angle

Rotation matrix | wikipedia.org in section that says "in three dimensions". It's the first search result when searching about rotating a vector about an axis. Let me know if you have any questions. ...
Kyy13's user avatar
  • 121
1 vote

Morph Targets Normal adding math

It would seem that, in the second example, the morphNormals are targets while in in the first they are deltas. This explains the difference in math used between the two pieces of code.
Sebastián Mestre's user avatar
1 vote
Accepted

How can I draw a tube on basis of position and angle between two 3d points?

The simplest solution is to use a lookat matrix. This is a matrix calculated from a "eye" point, a "target" point and an up vector. The resulting matrix will then make the Z axis point from the eye ...
ratchet freak's user avatar
1 vote

intersection between line segments - narrowed precondition

the arbitrary line can be represented as $P = (x,y) = P_0 + \lambda. \vec{dir}$ (works in n dimensions, no special case). If your other line is $x=x_1$ simply inject this in to solve for $\lambda$ and ...
Fabrice NEYRET's user avatar
1 vote

intersection between line segments - narrowed precondition

The arbitrary line can be expressed as y = a*x+b (assuming it's not parallel to the y axis). If the other line is parallel to the y axis then you can simply fill ...
ratchet freak's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible