<JordanBrown>
InPhase would complex number support really require more than defining a constant i? (or more likely I)
<JordanBrown>
27*I+13 doesn't seem like an awful style.
<JordanBrown>
But then again I have never been enough of a mathematician to do anything useful with complex numbers, so what do I know?
<InPhase>
JordanBrown: Well actually that's more likely to collide with existing code. If you include something that uses complex numbers, but you used a variable I in your code, you'd break the included code.
<InPhase>
But supporting as 13+27i introduces no conflicts or ambiguities.
<InPhase>
(Provided there is no support for number-starting variables.)
<InPhase>
This is why every other language supporting this does it like 13+27i (math and physics convention) or 13+27j (engineering convention).
<InPhase>
I think we should probably choose 13+27i, because then we leave open the logic of 5+4i+6j+7k as a modality for defining quaternion literals, if we support implicit casting from complex to quaternion in some way that doesn't break anything.
<InPhase>
If we did 13+27*I though we'd need to deprecate and add warnings for lines like I = 5; J = 6; and K = 8;
<InPhase>
And that sounds more extreme to me.
guso78k has joined #openscad
JakeSays_ has joined #openscad
JakeSays has quit [Ping timeout: 260 seconds]
<guso78k>
what would be the direct advantage of having complex numbers in openscad. just having is not yet satisfying
<guso78k>
Ultimately "Value" must contain 2 values in instead of just a double
guso78k has quit [Quit: Client closed]
fling has joined #openscad
Yuzuruha has joined #openscad
drfff has quit [Read error: Connection reset by peer]
Yuzuruha has quit [Ping timeout: 268 seconds]
JakeSays_ is now known as JakeSays
howiemnt1 has joined #openscad
howiemnt has quit [Ping timeout: 276 seconds]
L29Ah has quit [Read error: Connection reset by peer]
JakeSays_ has joined #openscad
JakeSays has quit [Ping timeout: 245 seconds]
howiemnt1 has quit [Read error: Connection reset by peer]
howiemnt has joined #openscad
JakeSays_ is now known as JakeSays
nomike has quit [Ping timeout: 244 seconds]
J25k13 has quit [Quit: Client closed]
J25k13 has joined #openscad
L29Ah has joined #openscad
snaked has quit [Remote host closed the connection]
guso78k has joined #openscad
guso78k has quit [Quit: Client closed]
J25k13 has quit [Quit: Client closed]
J25k13 has joined #openscad
teepee has quit [Remote host closed the connection]
fling has quit [Remote host closed the connection]
califax has quit [Remote host closed the connection]
fling has joined #openscad
califax has joined #openscad
teepee has joined #openscad
teepee_ has joined #openscad
teepee has quit [Ping timeout: 264 seconds]
teepee_ is now known as teepee
J25k13 has quit [Quit: Client closed]
J25k13 has joined #openscad
fling has quit [Remote host closed the connection]
fling has joined #openscad
aiyion2 has quit [Remote host closed the connection]
aiyion2 has joined #openscad
J25k13 has quit [Quit: Client closed]
J25k13 has joined #openscad
L29Ah has left #openscad [#openscad]
rawgreaze has quit [Ping timeout: 252 seconds]
<JordanBrown>
The underlying implementation is straightforward enough, not a concern.
rawgreaze has joined #openscad
<JordanBrown>
As to "why"... I don't know. Like I said, I'm not enough of a mathematician to have ever done anything useful with complex numbers.
<JordanBrown>
Other people *have* done things they consider useful, but I have no idea whether those things would be relevant to 3D modeling.
<JordanBrown>
OTOH, the quaternion stuff that InPhase is talking about sounds like it's at least sort of relevant.
<InPhase>
guso78: Oh, I thought you dropped so I didn't answer. I guess you remain in a different form. Complex numbers are just a shortcut for doing some kinds of trig.
<InPhase>
Real and imaginary are just bookkeeping for 2 coordinates, with ways to do 2D rotation and scaling by multiplication.
<InPhase>
There is always another way to write out the equivalent with trig functions and/or matrices, and/or a vector of coordinate pairs.
<InPhase>
But as I've been trained in thinking that way, there have been some times where I think about an operation with complex plane stuff, and then I implement it in a more expanded way in OpenSCAD.
<InPhase>
So supporting it is just about giving that tooling for people who have learned how to do these operations as another thinking modality about working with 2D coordinates.
<JordanBrown>
Seems like a bad shortcut. Multiplying a Y coordinate by a Y coordinate (if it's meaningful at all) does not seem like it would result in an X coordinate.
<JordanBrown>
C++ lets you say 47i. In C, you have to say 47*I.
<InPhase>
JordanBrown: Yeah, that's not the way to think about multiplication in that space. Magnitude is scaling, phase is rotation, so every complex number is a vector, and that vector's magnitude and angle reveals the scaling and rotation that it corresponds to.
<InPhase>
JordanBrown: So addition is translation by a vector, and multiplication is scaling and rotation by a vector.
<JordanBrown>
Without really thinking it through, yes, I understand that.
<InPhase>
And one can quickly extract all the necessary values with complex exponentiation with e^z
<JordanBrown>
But complex (0,1) * (0,1) is (1,0), which doesn't seem to align with the vector usage.
<InPhase>
-1, because it rotates 1i by 90 degrees.
<JordanBrown>
yes, sorry, typo, result is (-1,0).
<JordanBrown>
But in vector-space, why does multiplying (0,1) by (0,1) yield (-1,0)? What do the two values *mean* that makes that make sense.
<JordanBrown>
?
<InPhase>
Well you just are taking one, and rotating and scaling by the other.
<InPhase>
Or the product of the two magnitudes, and the addition of the two phases.
<JordanBrown>
What units are they in?
<InPhase>
mm, the same as anything else.
<JordanBrown>
What does it mean to rotate by a coordinate?
<InPhase>
The two angles from positive x, or the (1,0) direction, are added together.
<JordanBrown>
OK, starting to get it.
<JordanBrown>
(thinking)
<JordanBrown>
so when you multiply (x1,y1) by (x2,y2) you get (x1*x2+y1*y2, x1*y2+x2*y1), right?
<JordanBrown>
Does that really result in the right angle? I'm not saying it doesn't, just that it isn't instantly obvious to me that it would.
nomike has joined #openscad
<JordanBrown>
But also it seems like this totally falls apart when you want to move from 2D to 3D.
<InPhase>
You'll want -y1*y2 there. But yeah, it's totally not obvious when looked at that way. It's obvious when looked at through the scaled Euler formula m*e^(i*phi) = m*cos(phi) + i*m*sin(phi) The right side is the 2D vector coordinates, and the left side more obviously obeys the specified properties under multiplication, as m1*e^(i*phi1) * m2*e^(i*phi2) = m1*m2*e^(i*(phi1+phi2))
<JordanBrown>
... eyes cross ...
<InPhase>
Yeah. Complex only does 2D. Quaternions do 3D through 4D, and can be a bit more complicated. I frankly do not have a strong quaternion intuition built up, but I did find a good description that helps justify it through an analogy to bivectors that I found somewhat helpful. It has a nice clickbaity title: https://marctenbosch.com/quaternions/
<JordanBrown>
yeah, sorry, I dropped the "i" factors from the y1*y2.
<JordanBrown>
(For background, I did well in HS math through, but not including, calculus. Calculus was the first math class where I actually had to do the homework to learn the material, and I figured that out too late.)
<JordanBrown>
So I know what integrals and derivatives and limits *are*, but am very weak on actually doing the math.
<JordanBrown>
And anything beyond that, no.
<InPhase>
Calc 2 was my first math class where I had to actually study material. It slapped me around for half a semester before I got my act in gear. It was my first undergrad semester, and required some updated mindsets from me. :)
<InPhase>
My calc1 class experience is perhaps best exemplified by the time I had my head down and was TRYING to take a nap, when I hear another student complain, "How come HE gets to sleep?" after the teacher insisted he pay attention. I popped my head up, the calc teacher turned to me and pointed to the board and said, "What's the answer to this?" for the problem he was about to explain how to do. I answered
<InPhase>
it. He said, "Okay, you can put your head down."
<JordanBrown>
I went straight from HS to a programming job; I never went to college. That was easier 40 years ago when there weren't very many programmers.
<JordanBrown>
:-)
<InPhase>
So I had yet to learn studiousness. lol
<JordanBrown>
Yeah, I never really learned that.
<JordanBrown>
Most stuff came easily and naturally.
J25k13 has quit [Quit: Client closed]
J25k13 has joined #openscad
<JordanBrown>
I was quite concerned when I starting working on programs that were so large that I couldn't keep the entire thing in my head; I wasn't sure that I could figure out how to scale past that limit.
<InPhase>
Yeah. First semester of undergrad I learned the hard way to stop relying on that. I did better then. It was just a delayed lesson. I think that would have gone easier had I been challenged to the point of failure at some prior time. Everyone needs some of that.
<JordanBrown>
Yes.
<JordanBrown>
I still don't know how to study, per se. But I'm really good at modularity and interfaces, so I can compartmentalize stuff and treat it as a black box until I need to look inside.
<JordanBrown>
Anyhow, going back to complex arithmetic, if it happens that complex arithmetic and 2D vector arithmetic are the same, in a meaningful way, then I withdraw my objection to the shortcut.
<JordanBrown>
Except that until you extend complex arithmetic to more than two dimensions (which sounds like what quaternions do), it seems too limited to be useful.
<InPhase>
It has two utilities. One is analogous to working with polygons and extruding.
<InPhase>
The other is sometimes for stuff that should be oscillating.
<InPhase>
Like you can also potentially work with wavy features this way.