求一个关于射击方面的游戏的问题,拜托帮助

具体的如图,我现在数学就是小学六年纪的水平,谁能帮忙看看?关于数学方面的问题
如图,已知起点和A点,如何得出B点和C点来?B和C保持在A点的两边,A可能是任意方向,其实就是想做散弹枪子弹的射击,射出A点,附加上B和C点,就是不知如何计算B和C点的终点位置来,最好能帮忙给个代码,我数学真的就小学水平。。我知道这应该是求圆,所以捣鼓了一天的代码,结果还是有个问题无法解决,代码如下
Vec2 pos1;
auto start = m_vHeros->getPosition();
auto end = touchLocation;
auto r = start.getDistance(end);
Bullet::createWithBulletType(m_map, start , end, 0);

pos1.x = start.x + r * cos(20 * 3.14f / 180);
pos1.y = start.y + r * sin(20 * 3.14f / 180);
Bullet::createWithBulletType(m_map, start , pos1, 0);

pos1.x = start.x + r * cos(-20 * 3.14f / 180);
pos1.y = start.y + r * sin(-20 * 3.14f / 180);
Bullet::createWithBulletType(m_map, start , pos1, 0);

结果以下代码的B和C二点位置永远是固定的,我试了下应该是要20和-20那个地方应该是要动态求A的角度吧才能固定在A的两边吧?但是我不知如何做,谁能帮帮忙?

你的计算公式里面没有A的坐标变量,全是固定值,当然永远是固定的。
绕原点逆时针向量旋转公式(顺时针旋转就把角度B变为负):

x1 = x0 * cosB + y0 * sinB
y1 = -x0 * sinB + y0 * cosB

具体到你的例子,应该是

auto xA = end.x - start.x;
auto yA = end.y - start.y;
pos1.x = start.x + xA * cos(20 * 3.14f / 180) + yA * sin(20 * 3.14f / 180);
pos1.y = start.y - xA * sin(20 * 3.14f / 180) + yA * cos(20 * 3.14f / 180);
Bullet::createWithBulletType(m_map, start, pos1, 0);

pos1.x = start.x + xA * cos(-20 * 3.14f / 180) + yA * sin(-20 * 3.14f / 180);
pos1.y = start.y - xA * sin(-20 * 3.14f / 180) + yA * cos(-20 * 3.14f / 180);
Bullet::createWithBulletType(m_map, start, pos1, 0);
2赞

十分感谢大大的帮忙,问题解决了!!太感谢了:grin:

你们小学六年级学三角函数了?瑟瑟发抖。