I have one big circle and I have small circles around it as its children now I am facing an issue is their angle rotation I want to rotate the children's circles so that their 90 degrees is towards the center of their parent circle which is (0, 0). how to do that if given the x, y of each child circle.
<>
{(circles || []).map((circle, idx) => {
const pathRadius = circle.childrenRadius;
const pathD = `
M ${-20},${pathRadius + 5}
C ${-pathRadius - 50} ${-pathRadius - 28}, ${pathRadius + 50}
${-pathRadius - 28}, ${20} ${pathRadius + 5}`;
return (
<g
onClick={() =>
setActiveTable({ data: circle, index: idx, type: "round" })
}
key={circle.id}
className={`table round-table table-${idx}`}
id={idx}
transform="translate(200, 200)"
>
<g className={`round-table-inner table-inner-${idx}`}>
<circle
id={idx}
className={`circle circle-${idx}`}
r={circle.radius}
></circle>
<TableTitle
className={`svg-text round-title-${idx}`}
idx={idx}
title={circle.title}
degrees={-90}
/>
<ScalePointer
className={"arrow"}
idx={idx}
y={-circle.radius}
x={0}
/>
<RotationPointer
className={`rotate-pointer pointer-${idx}`}
idx={idx}
y={0}
x={circle.radius}
/>
{circle.children.map((childrenCircle, index) => {
const numChildren = circle.children.length;
const x = (circle.radius + 45) * Math.cos(angle);
const y = (circle.radius + 45) * Math.sin(angle);
// const personName = "Nathan Drake is the name"; //limit 36
// Calculate the path for the circular text
const pathId = `path-${idx}-${index}`;
const theta = Math.atan2(0 - y, 0 - x);
const dx = x - 0;
const dy = y - 0;
//Person Name alignment
if (x < 0) {
angle = 270 - (Math.atan(y / -x) * 180) / Math.PI;
} else {
angle = 90 + (Math.atan(y / x) * 180) / Math.PI;
}
return (
<ChildCircle
handleChild={handleChild}
x={x}
y={-y}
index={index}
idx={idx}
degrees={angle}
childrenRadius={circle.childrenRadius}
pathD={pathD}
pathId={pathId}
personName={childrenCircle.title}
/>
);
})}
</g>
</g>
);
})}
</>
</React.Fragment>