Archive for August, 2019

Potentials – Adding Arrows to Electric Field

Thursday, August 29th, 2019

Building Great Code

This morning I finished adding in the directional vectors to the display of the electric field on the Potentials app. Previously, we had the color indicate the magnitude of the field at each point, and then the contours were for lines of equal strength. But that's not really all that helpful for an electric field map - better, that each point have a little arrow indicating the direction of the field at that point. Then, you can see the shifting direction of the field, and where a test charge would feel force in the field.

The approach was to start with the points for line segments for the graphics primitives, and then modify them to suit the needs of each point. For example, assume an arrow, pointing to the right, lying on the x-axis, centered at the origin, and fitting with the unit square. There are five endpoints needed to draw these lines in one stroke, so lay them out. This is the starting point for all arrows.

Then we need to rotate it by the angle of the electric field at each point. This is in radians, and we can do this with the CGAffineTransform:

  CGAffineTransformMakeRotation(dir)

where dir is the angle of the field at that point.

Then we can scale the arrow for the size of the box in the view with:

  CGAffineTransformMakeScale(fac, fac)

because we want to look at the minimum size of the box, and call that fac.

Finally, we can move the arrow to the correct place in the view with:

  CGAffineTransformMakeTranslation(x+dx/2.0, y+dy/2.0)

And of course, we can use CGAffineTransformConcat to put these all together into one transformation that can then be applied to each point in the line segment:

  CGAffineTransform    xfrm = CGAffineTransformConcat(
                                CGAffineTransformConcat(
                                  CGAffineTransformMakeRotation(dir), 
                                  CGAffineTransformMakeScale(fac, fac)),
                                CGAffineTransformMakeTranslation(x+dx/2.0, y+dy/2.0));

because you can't call CGAffineTransformConcat with three arguments.

The results are just fantastic:

Electric Field Vectors

and it's easy to track where the test charge will feel the force of the field in every point in the workspace. This is just what we were hoping to get, and it wasn't all that hard with a standard arrow, and then a set of transformations.

Nice. 🙂

Quick Update on the Apple Card

Wednesday, August 21st, 2019

AppleCard

Just a little update on the Apple Card, and how it's been to use, now that I've had the physical card in-hand for a week now. In short - the card is physically very nice - I like the heft and the fact that it's got no identifying marks on it but my name, and that it doesn't get deformed in my wallet. But what's really setting it apart is the Wallet app on my iPhone.

Apple Card

I had been using the Capital One Quicksilver card, and still carry it now - but all my recurring expenses, and online services, have moved over to the Apple Card. The Capital One app had notifications, and that's become pretty much table stakes for credit cards these days - my Bank has it, Capital One, and Apple. But it's the frictionless nature of the Apple experience that is really what this card means to me: Service.

A card is a card - I'm one of the very lucky ones that doesn't have to worry about interest rates - I pay it off every month - without fail. So the limit matters, but only a little, and so it's really the services, the help in tracking purchases, verifying that they are correct, and in a timely manner - that I really care about. And in that regard, the Apple Wallet app is just going to be so much better at it than the Capital One developers - because they only have to build for one platform (theirs), and they have the advantage of handling security in any way they want.

It's made it much easier to see what's happening, keeping track of the charges/purchases, and the easy way to see what gets the different cash-back percentages has been baked-into the UI on the list of charges. It's really quite good. But that's the point - Apple is going to be focused on the Service and experience of the user, and not on the financials that another issuer will be.

I have to say, I'm really enjoying it. 🙂

UPDATE: I followed the advice on Daring Fireball to opt-out of the arbitration clause on the Apple Card, and it could not have been easier. Everything was done in the Messages app... just go into the Wallet, hit the three-dots, and select Message, and text that you want to exercise your right to reject the arbitration clause.

They will transfer the chat conversation to a Goldman employee, and then they will see it, and mark you down as having opted-out of the arbitration clause, and that's it. No mess. No fuss. This is the way technology should empower us.

Moving to Leiningen 2.9.0 and Ultra 0.6.0

Wednesday, August 21st, 2019

Clojure.jpg

This morning I decided to see about the status on one of my favorite Leiningen plugins - Ultra, the formatter, highlighter for the REPL. It makes things so much easier to see and read at a glance, and follow along quickly with the output of a function, or the values in some input. It's really what syntax highlighting did to text editors. Very nice.

Anyway... I found that Ultra 0.6.0 was up on Clojars, and so I was able to move to Leiningen 2.9.0 in Homebrew with:

  $ brew switch leiningen 2.9.0

and then I changed my ~/.lein/profiles.clj to be:

  {
   :user {:plugins [[lein-exec "0.3.7"]
                    [venantius/ultra "0.6.0"]]
          :ultra {:color-scheme {:delimiter [:bold :yellow]
                                 :tag [:bold :yellow]
                                 :nil [:cyan]
                                 :boolean [:bold :cyan]
                                 :number [:bold :green]
                                 :string [:bold :red]
                                 :character [:cyan]
                                 :keyword [:yellow]
                                 :symbol [:bold :magenta]
                                 :function-symbol [:bold :blue]
                                 :class-delimiter [:blue]
                                 :class-name [:green]
                                 :exception [:bold :red]}}
         }
  }

and then I was ready to go.

One downside of moving to Leiningen 2.9.0 is that nREPL 0.6.0 formats the output a little differently, and it places an additional newline on the end of the output, so that it now appears to have a "double spaced" output:

Leiningen Differences

where the top REPL was using the old nREPL in Leiningen 2.8.3, and the bottom one was using Leiningen 2.9.0 with nREPL 0.6.0. Now the developers may come to terms with this, and clean this up, or at least make it optional, but for now, I'm willing to live with the extra line as just "part of life"... as I really wanted to get to Ultra 0.6.0 and Leiningen 2.9.0 - due to it's significant structural changes under the hood.

Progress isn't always without a few bumps in the road...

Decided to try Morning Brew

Tuesday, August 20th, 2019

WallSt.jpg

This morning, I noticed that, once again, Daring Fireball had an add for Morning Brew - a market data daily email, that is no doubt selling subscriber name and information, but I decided to give it a try, and see what it was all about. I noticed on the sign-up page that it was seemingly meant for a phone form-factor, and that got my interest up even more, so I subscribed for the email account on my iPhone, and we'll see how it works out.

With the fun little investing I'm doing with Robinhood, it seems like something that might be a nice diversion in the morning to have something to read that's compact, easy to read, and got some useful information that I might have missed in my Apple News+ feed this morning.

We will see how it works out. Maybe nothing, maybe something really nice. 🙂

Signed Up for the Apple Card

Monday, August 12th, 2019

AppleCard

I got an invitation to sign up for the Apple Card last week, and went through the sign-up process in the Wallet app, and found out that it was going to be pretty much as good as my Capital One Quicksilver card - with the added security features of not having my purchasing history sold. It's something that I was really looking forward to when it was announced at WWDC.

Today, the physical card arrived, and I'll activate it when I get home, but so far, the card is working exactly as promised. I do a lot of Apple Pay, and that's all working just fine. I had to Add a Card on my Mac and iPad - but the Apple Card was there, and it was easy to add, and other than that, it's just so easy. Nothing fancy about the purchase classifications, but it's nice... and the details come up a little faster than the old Capital One app - but that wasn't all that bad.

It'll be interesting to see the card, and see how the payment feature works. I have to admit, it's a little different to have my iPhone link to my Bank, as opposed to using the online bill-pay system from my Bank - but either way - it works, and the effect is the same.

Life keeps adding little smiles... 🙂