question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Partial derivatives, Rotor/Curl of a field, Normal of a surface

See original GitHub issue

Two separate-but-related differential operators that seem pretty important/essential to me for 3D math:

  1. Rotor/Curl - https://en.wikipedia.org/wiki/Curl_(mathematics)

I’ve managed to get the rotor of a given field at the point [X,Y,Z] in the following example: https://www.math3d.org/MrIboI6x

Notice that I had to define 9 intermediate functions in order to accomplish this… not great fun. I also wasn’t able to use this method to create a generic rotor function, because I had to use the constants X,Y,Z in the intermediate functions.

  1. Surface normal - https://en.wikipedia.org/wiki/Parametric_surface#Tangent_plane_and_normal_vector

(note that I mean the un-normalized vector Ru×Rv)

Again, I was able to do this for a single point using two intermediate functions: https://www.math3d.org/3Iqv6XXf

I’ve looked through math in the console and math.js, and wasn’t able to find a ready-made way to calculate these at given coordinates. Please add one, and/or make an example of it so it’s more discoverable!

What these two things have in common: they involve partial derivatives. I’ve tried using diff with functions of multiple variables, but I just can’t find a way to work with them! If you can expose them a little better to the end-used, that might help.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ChristopherChudzickicommented, Nov 22, 2019

Note to self: This is implemented but still needs documented examples.

1reaction
NeatNitcommented, Jul 3, 2019

I understand that diff(f,x,y,z) returns a matrix, where each partial derivative is a row (or column?) in the matrix, but I can’t find a way to get one row(/column) of the matrix as a 3D vector. There is no row function, see https://github.com/josdejong/mathjs/issues/230

Edit: I can’t tell you how many failed attempts this took me: https://www.math3d.org/UdFijsnH

Apparently I was using subset/index wrong. To get the partial derivative of R(u,v) in regards to u, apparently we use:

Ru(u,v) = flatten(subset(diff(R,u,v),index(1,[1,2,3])))

I was stuck for hours trying to figure out why index(1,[1,3]) wasn’t working. This would have been easier to solve if I could actually see the values that were being output.

This is related to the “see something’s type” topic discussed here: https://github.com/ChristopherChudzicki/math3d-react/issues/193#issuecomment-505530098, but for variables (that aren’t functions) we might as well be able to see the actual output value - preferably as a nicely formatted matrix/table.

I know I’m making a lot of requests, some of which are big, but it’s only because I like this software so much and want to see it improve. 😃

(I will try to make some PRs eventually, but for the next ~month it will definitely not be possible)

Edit: Curl still requires partial derivatives as intermediate functions, but at least it can be made generic: https://www.math3d.org/bNLU7FfY - RotF(x,y,z) here works for any x,y,z.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unit normal vector of a surface (article) - Khan Academy
Partial derivatives of parametric surfaces ... To compute surface integrals in a vector field, also known as three-dimensional flux, you will need to...
Read more >
14.3, 14.4 Partial Derivatives and Tangent Planes
The partial derivative of f(x,y) with respect to x is ∂∂xf(x ... To compute the normal to the surface, we take partial derivatives:...
Read more >
Curl (mathematics) - Wikipedia
In vector calculus, the curl is a vector operator that describes the infinitesimal circulation of a vector field in three-dimensional Euclidean space.
Read more >
Finding a surface normal of implicit surface f(x,y,z)
I've tried normalizing the vector made up of partial derivatives of x, y and z, but that seems to be failing for some...
Read more >
Surfaces and Partial Derivatives - YouTube
Free ebook http://tinyurl.com/EngMathYTLecture on the mathematics of surfaces and partial derivatives. Levels curves are discussed and how ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found