How to make a circular heat map or diagram in Mathematica?

Is there any way to make a circular heat map in Mathematica?

Thanks for your help!

Here is a toy example for regular heat map. Can anyone help me make it to a circular one?

data1={{9., 1., 6., 7., 6., 3., 1., 3., 10., 2., 2., 5., 2., 5., 3.,    1.}, {5., 5., 5., 4., 4., 6., 4., 6., 9., 1., 2., 10., 2., 1., 1.,    6.}, {2., 7., 6., 2., 8., 10., 8., 9., 2., 5., 3., 9., 7., 8., 7.,    5.}, {6., 6., 2., 1., 8., 2., 8., 3., 8., 5., 5., 4., 6., 2., 3.,    6.}, {8., 1., 8., 2., 5., 8., 5., 3., 5., 3., 4., 2., 2., 4., 4.,    1.}, {10., 2., 8., 10., 3., 6., 1., 9., 3., 5., 2., 5., 1., 3., 7.,    9.}};  ArrayPlot[data1, ColorFunction -> ColorData["LightTerrain"],   Frame -> True,   FrameTicks -> {{{{1, "r1"}, {2, "r2"}, {3, "r3"}, {4, "r4"}, {5,        "r5"}, {6, "r6"}}, None},    {None, {{1, "c1"}, {2, "c2"}, {3, "c3"}, {4, "c4"}, {5, "c5"}, {6,        "c6"}, {7, "c7"}, {8, "c8"}, {9, "c9"}, {10, "c10"}, {11,        "c11"}, {12, "c12"}, {13, "c13"}, {14, "c14"}, {15, "c15"}, {16,        "c16"}}}},   Epilog -> {Text["Sector1", {2, 8}], Text["Sector2", {6, 8}],     Text["Sector3", {10, 8}], Text["Sector4", {14, 8}]},   ImagePadding -> {{20, 20}, {20, 80}}, ImageSize -> Large] 

enter image description here

I want to make a circular diagram like the following one.

enter image description here

Reference: https://stackoverflow.com/questions/62556246/how-to-plot-the-variant-circular-bar-chart-in-r-with-ggplot

Is it possible to make a one like this?

enter image description here

Thanks a lot!

How to Make GameObject move in Circular Motion

I’ve been trying to work an enemy that moves in a circular motion for my RPG game, but for some reason, whenever I press play the GameObject instantly goes hundreds of units in the X and Y coordinates. It also move back to -1 on the Z axis. Here’s the script to my enemy’s movement:

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class EnemyScript : MonoBehaviour {      private Rigidbody2D rb;      [SerializeField]     float rotationRadius = 2f, angularSpeed = 2f;     float posX, posY, angle = 0f;      // Start is called before the first frame update     void Start()     {         // Gets the RigidBody2D component         rb = GetComponent<Rigidbody2D>();     }      // Update is called once per frame     void Update()     {         Movement_1();     }      void Movement_1()     {         posX = rb.position.x + Mathf.Cos(angle) + rotationRadius;         posY = rb.position.y + Mathf.Sin(angle) + rotationRadius;         transform.position = new Vector2(posX, posY);         angle = angle + Time.deltaTime * angularSpeed;          if (angle >= 360f)         {             angle = 0f;         }     } } 

How can I set up a 2D circular boundary in Unity?

I wanted to create a virtual analogue stick on Unity. enter image description here

I figured a very simple, 2 part method setting up a tether to the middle of a doughnut-container and a boundary would work. While the tether was quickly solved just by using Vector2.MoveTowards, the boundaries would be much harder to solve.

I initially tried to create a 2D circle collider around the doughnut-container but I didn’t know how to reverse its collisions to keep the cursor inside. Later, I tried to set up a square shaped boundary by setting up the limits of the x and y coordinates the cursor cannot exceed (these limits were also made according to the doughnut-container). Thus was done with multiple if statements:

 if (currentPoint.y >= 2.7f){currentPoint.y = 2.7f;}  if (currentPoint.x >= 2.5f){currentPoint.x = 2.5f;}  if (currentPoint.y <= -2.7f){currentPoint.y = -2.7f;}  if (currentPoint.x <= -2.5f){currentPoint.x = -2.5f;} 

However, when testing the code out, the cursor still exceeded the boundaries given:

enter image description here

Minimum reproducible code for the cursor:

public class menuScript : MonoBehaviour {     public float speed;     public Vector2 originPoint;     private Vector2 currentPoint;     // Start is called before the first frame update     void Start()     {         Vector2 originPoint = transform.position;     }      // Update is called once per frame     void Update()     {         currentPoint = transform.position;         float step = 50 * Time.deltaTime;         float vertical = Input.GetAxis("Vertical") * Time.deltaTime * speed;         float horizontal = Input.GetAxis("Horizontal") * Time.deltaTime * speed;          if (horizontal != 0 || vertical != 0)         {         transform.Translate(horizontal, vertical, 0);         if (currentPoint.y >= 2.7f){currentPoint.y = 2.7f;}         if (currentPoint.x >= 2.5f){currentPoint.x = 2.5f;}         if (currentPoint.y <= -2.7f){currentPoint.y = -2.7f;}         if (currentPoint.x <= -2.5f){currentPoint.x = -2.5f;}         }         else         {             transform.position = Vector2.MoveTowards(transform.position, originPoint, step);         }              } } 

Circular movement in 5th edition d&d

This came up in a discussion in my group about circular movement.

Do we treat this as moving diagonally or difficult terrain?

For a situation such as circling a target on a horse shooting arrows at it we fell should be treated as difficult terrain

One situation was mentioned was what if a ranger casts spike growth which has a 20 foot radius wants to completely walk around it. How long would it take? The circumference is about 125 feet and ranger base speed is 30

This came up as we wanted to know if we cast spike growth catch someone in the area of effect. If they try to move out from it and away from us can we circle around faster then they can move through it

Running through it counts as difficult terrain but what about running around it?


Linear Partition problem (Dynamic Programming) in a circular array

I am practicing algorithms for the last couple of days and I came across this question, the gist of which is:

Given apples and oranges arranged in a circle indexed form 1 to n , where n is an odd number(we know which ones apple and which ones orange), divide these into k contiguous groups each havind odd number of fruits such that most of the groups have more apples than oranges. Also, the arrangement can be such that a group can contain fruits of indices (n-3, n-2, n-1, n, 1 , 2, 3).

This appears like the linear partition problem to me, but the circular arrangement confuses me. Also, I was thinking of masking Apples as 1 and Oranges as -1 so that it’s easy to calculate the which one is higher in the group( if sum is +ve, then apples are higher else oranges). Also, I observed that k must be an odd number as n is an odd and each of the k groups have odd fruits, so sum of odd number of odds is an odd number.

We have to maximize the sum of each of the groups in this case right?

It would be great if someone can help out.

Thanks a lot!!!

Walk around a coordinate in circular order to a distance of N

For my development purpose, I need to work on all the 2D coordinates (in whole number) around [0,0] from 0 to N distance. For example, with N=1, I need

N0: [0, 0] N1: [-1, -1] [0, -1] [1, -1] [1, 0] [1, 1] [0, 1] [-1, 1] [-1, 0] 

The order is important. I want to walk these values in a circular way, starting from 0, incrementing the distance each round.

I first created two for-loops, from -N to N on each axes, but the resulting order is the one as you read a book: from top left to bottom right.

Here’s the order I aim (the first coordinate to walk on each circle is not important):

walking order

Here’s a first algorithm I tried, in pseudo code

int totalSize = (2*N+1, 2)*(2*N+1, 2) Vector2[] coordinates = new Vector2[totalSize] int index = 0 coordinates[index++] = new Vector2(0, 0) for (int d = 1; d <= N; d++) {     for (int x = -d; x <= d; x++) {         coordinates[index++] = new Vector2(x, -d)         coordinates[index++] = new Vector2(x, d)     }     for (int y = -d+1; y <= d-1; y++) {         coordinates[index++] = new Vector2(-d, y)         coordinates[index++] = new Vector2(d, y)     } } for (int i=0; i<coordinates.Length; i++) {     print(coordinates[i]) } 

But:

  • It seems too cumbersome. I don’t like the creation of a scructure that retains the coordinates. And 4 for-loops seems not optimized.

  • The order of the circles is ok, but the order inside each circle is not the one I described.

  • I have the feeling trigonometry can help me, but I can’t see how to implement it on discrete values

Any idea?

How To Merge Together Two Circular Doubly-Linked Lists In O(1) Time?

I’m implementing a Fibonacci Heap, where the lists are stored as a circular doubly-linked lists. What I’m trying to do is given a pointer to a random node in one linked list, and a random node in another, I want to merge them together in O(1) time. I tried drawing this out, but I couldn’t seem to figure out how to do this. Here is my first idea, in pseudocode:

union(Node one, Node two) {     if other = nil         return      p1 = one     p2 = one.right     p3 = two     p4 = two.right      p1.right = p4     p4.left = p1     p2.right = p3     p3.left = p2 } 

Each Node has a left and right attribute, which stores the node to the left and right, respectively. However, this didn’t work. Can anyone figure out how to merge together two linked lists?