How to draw an animated point to point line in grapher

I am using grapher and want o create some animations for a PHY class. I have figured out how to animate a dot moving in a circle, and what I am trying to do is draw a line from the dot as i moves around to a fixed point. What I have is a t=0 as my parameter, and I am using the animate parameter function with a like matrix set up in x,y, where x=cos(t) and y = sin(t). I also managed o have a line go from the center to the dot and follow it around, but I want the line to stop at the dot and set it up so it runs from off-center. (The whole point is to illustrate the difference between distance from a starting point and displacement).

Anyhow this is what I have so far, if anyone has suggestions that would be most appreciated. (I want to draw a line from the edge of the circle on the x-axis to the blue dot, so you can see the length change as it moves) enter image description here

architecture – DDD in microservices – where to draw the line of responsibility of a microservice?

It is pretty common for one microservice to need data from another microservice to service their consumers (in the form of API responses). Fetching data synchronously couples the two microservices tightly. Leaving it to the consumer to fetch data from another Microservice can lead to chatty APIs and slow response time.

A few conventions to confirm your domain model and push it further to arrive at the solution you are looking for:

Bounded Contexts make good Microservice boundaries.

One Bounded Context (BC) can contain more than on microservice, but one microservice should never span across BCs. A domain concept makes sense only when considered within a BC. It may mean something else in a different BC.

Your boundaries – Product Management and “Recommendation” Engine- seem to be correct, IMHO.

The concept of Product may mean one thing in the Product Management Microservice but can be subtly different in the Recommendation Microservice. The differences can be structural or behavioral.

Microservices share nothing.

All data and APIs related to the Microservice are enclosed within it. If another Microservice needs this data, they are exposed as well-defined services (RPC-based communication, for example) or as APIs (REST-based, for example). Accessing another microservice’s data via the database is strictly forbidden.

Microservices are connected over a common message channel.

Data points that are related to multiple microservices are published on a common channel as Events. Interested Microservices have subscribers watching out for the event, pick it, and process it for internal use. In DDD parlance, these are Domain Events.

An Aggregate in one Microservice could be a Value Object in another.

Product Management BC is the owner of Product-related data. Other microservices may retain/cache portions of that data within their boundaries (like you are doing with Product IDs, in your case).

Read models can be used to serve APIs with different needs.

You can populate a read model with data prepped and ready to be served in API responses. In your example, you would have a row (or multiple rows) per user in the read model with ready-to-ship data in the Recommendation Microservice.

There can be more than one read model per data structure, as dictated/required by API responses.

It’s perfectly valid to construct and store data in different formats to cater to different APIs. You would use Domain Events with a pub-sub model to populate these read-only data structures in the background.

An API request should be handled in entirety by one single Microservice.

Unless you are using reactive architectures and you can gather data from microservices in parallel, you are better off dealing with the request within one single Microservice in entirety.


So there is a third option of storing a copy of Product data (only what you need) as part of the Recommendation Microservice and using it when constructing the response for Hot Products.

The Product data here is treated as a cache, populated in the background (typically by listening to events being published from the Product Management Microservice), and should be reconstructable in entirety. Most importantly, the Recommendation engine should treat this data as read-only, and not add any additional metadata into it.

architecture – DDD in microservice – where to draw the line?

So our retail website has a microservice that is responsible for Products data:

Do a GET for a product ID and get all the product’s info (image, price….).

We have a new feature on the website – Hot products

So we have a new microservice that is responsible for the business logic of finding what are the relevant products for that specific website user and return them to the caller (e.g. productIds: 456, 789).

On the website, we need to display more data about the product (image, price,….). This data is in the products microservice.

And here comes the question:

Who is responsible to translate the Hot products‘s meager IDs recommendations into something that the Website can use?

Option 1 – The Hot products will also take care of that. Instead of returning only a list of IDs, will call the Products service in order to bring all the data that is needed and return a much richer response to the caller.

Option 2 – The Hot products will keep on returning only the IDs of the products, and it is up to the caller responsibility for doing with the data whatever it needs – e.g. calling the Products microserivce to bring the data it needs.

Drawbacks of option 1 – more work on the caller side

Drawbacks of option 2 – involving the display/usage business logic of “what needs to be done with the hot products” into the business logic of the Hot Products microservice. If another caller needs different product information (e.g. brand) the Hot products microservice needs to changed or at least “know” about it

So where is line of responsibility or “Domain Driver Development” in such case?

How to draw chunks of a map within view of camera

I want to draw chunks of a map in the screen when it’s visible by the camera.

I can draw a single chunk using:

map(celx, cely, screenx, screeny, 16, 16)

This draws the chunk celx cely to the screen position screenx screeny.

I can move this map where it’s drawn using:

camera(camx, camy)

This will offset the map by vector camx camy.

This is basic PICO-8 api.

For my problem, I define a world by chunks of the map:

pworld = {
   0, 1, 2, 0, 3, 4, 0, 1, 2,
   0, 3, 4, 0, 3, 4, 0, 3, 4,
   0, 1, 2, 0, 1, 2, 0, 1, 2,
   0, 1, 2, 0, 1, 2, 0, 1, 2
}

World is laid out by chunks of 8×4 units.

0 means chunk where celx=0 cely=0
1 means chunk where celx=1 cely=0 and so on.

Now when the camera is at say x=10,y=10 I have to draw the portion of the world indexes 1,2,9,10:
I tried to calculate this using:

function v_map(x, y)
   local i = pworld(flr(y/16)*8+flr(x/16)+1)

   local my = flr(i/8)
   local mx = i%8

   return {
      {x=mx,y=my},
      {x=mx+1,y=my},
      {x=mx,y=my+1},
      {x=mx+1,y=my+1}
   }
end

and draw using:

function _draw()

  camera(cam.x, cam.y)

  local vm = v_map(camx, camy)
  map(vm(1).x, vm(1).y, 0, 0, 16, 16)
  map(vm(2).x, vm(2).y, 0, 0, 16, 16)
  map(vm(3).x, vm(3).y, 0, 0, 16, 16)
  map(vm(4).x, vm(4).y, 0, 0, 16, 16)
end

But this is wrong and I don’t understand how this even should work.
How do I know the indexes of the chunks to draw?
How do I know at what screen position to draw the chunks?
How does this work well with moving the camera?

plotting – How to draw tilted axes for spacetime diagrams

I want to use Mathematica to draw spacetime diagrams.
In particular, on one of these diagram, I’d like to draw two pairs of axes —
the first pair (t,x) for the rest frame
and the second pair (t primed, x primed) for the moving frame.
Further, the axes for the moving frame should be tilted towards the t=x line.
Q1: Is there a way to do this?
Q2: Is there a Mathematica package out there that does?
Thank you
Fritz

unit testing – Draw Data Flow Graph with Constructor and Functions

I am new to software testing and would like to know whether it’s appropriate to draw a data flow graph that flows from initiation of variables to constructor and method.

Is there something wrong with this data flow graph?

class car {

  string brand; // 1
  int age; // 2

  car(string brandName, int year)
  {
     brand = brandName; // 3
     age = calAge(year); // 4
  }

  calAge(int year);
  {
   return DateTime.Now.Year - year; // 5
  }
}

enter image description here

plotting – Why “Joined” does not draw all the lines?

I’m working on a project in order to plot a graphical method for finite-difference equations called cobweb method. The next figure was succesful try for

$$x_{t+1} = Rx_t – frac{R}{2000}x_t^2$$

enter image description here

But, when I try with

$$x_{t+1} = cos{x_t},$$

and copy-paste the code I used before, the result was

enter image description here

For some reason Joined->True doesn’t draw all the lines. Changing a litle bit the number of point plotted, from 17 to 16, the figure is correct

enter image description here


There is a problem, but, where? My code is the following

difEqu(x_) := N(Cos(x))

traFin = {{0.4,0},{0.4,0.921061},{0.921061,0.921061},{0.921061,0.604976},
 {0.604976,0.604976},{0.604976,0.822516},{0.822516,0.822516},{0.822516,0.68038},
 {0.68038,0.68038},{0.68038,0.777334},{0.777334,0.777334},{0.777334,0.712786},
 {0.712786,0.712786},{0.712786,0.756543},{0.756543,0.756543},{0.756543,0.727213},
 {0.727213,0.727213},{0.727213,0.74703},{0.74703,0.74703},{0.74703,0.73371},
 {0.73371,0.73371},{0.73371,0.742695},{0.742695,0.742695},{0.742695,0.736649},
 {0.736649,0.736649},{0.736649,0.740724},{0.740724,0.740724},{0.740724,0.73798},
 {0.73798,0.73798},{0.73798,0.739829},{0.739829,0.739829},{0.739829,0.738584}}

extremos = {{0.4,0},{0.739829,0.738584}}

Show(
 Plot(
  Evaluate(
   {Legended(Style(difEqu(x), RGBColor(0., 0., 1.), Thickness(0.004)),"x(0) = 0.6"),
   Legended(Style(x, RGBColor(0., 0., 0.), Thickness(0.004), Dashed),"Identidad")}
  ),
 {x, 0, 1},
 PlotTheme -> "Scientific",
 ImageSize -> Large,
 PlotRange -> Full,
 FrameLabel ->
  {Style("x (t)", FontSize -> 35),
  Style("x (t+1)", FontSize -> 35)},
  LabelStyle -> {FontFamily -> "Arial", 20, RGBColor(0., 0., 0.)}
 ),
 ListPlot(
  {traFin, extremos},
  PlotStyle -> {{RGBColor(1., 0., 0.),Thickness(0.001)},{RGBColor(1., 0., 0.)}},
  Joined -> {True, False}
 )
)

I get traFin with another code. The number of iterations here is 16, i.e.

$$x_{16+1} = underbrace{x(x(cdots(}_{text{16 times}}0.4) = 0.738584.$$

call of cthulhu 7e – Can you use Sleight of Hand to draw a firearm during a surprise round to get the initiative boost?

I don’t really understand what you mean by “initiative boost” but you can get a free attack if you manage to surprise your opponent (overriding the DEX order just once, before reverting to combat rounds).

There’s an answer to that p.107 of the Core rules :

Of course if the target has their wits about them, they may see the attack coming. The Keeper may allow a skill roll to determine if the target anticipates the attack, using either Listen or Spot Hidden to hear or see it coming, or Psychology to perceive the attacker’s intent.

The Stealth skill of the attacker can be used to set the difficulty level for the investigator’s Listen, Spot Hidden, or Psychology skill, or vice versa if the investigator is the one making the surprise attack (remembering that the player should be rolling the dice where possible).

Depending on the outcome of the roll:

  • If the target anticipates the attack, they may choose to dodge or fight back.
  • If the target fails to anticipate the attack, the Keeper may allow the attack to be an automatic success (unless a fumble is rolled) or award the attacker a bonus die, depending on the situation. If the attacker is making a ranged attack (for example with a gun or throwing knife), a roll should always be made to hit.