小编Tes*_*ssa的帖子

如何在2D中从另一个矢量角度计算矢量?

我知道我应该知道这一点,但我无法弄明白/找到解决方案.我可以手工完成,但我不能把它放在算法中...(在c ++中工作,但伪代码应该没问题).

我有一个矢量,我想找到另一个基于角度的矢量.

两个向量的角度

v是已知的,角度α是已知的并且w的大小是已知的.我怎么能找到w?

谢谢!

math trigonometry

8
推荐指数
1
解决办法
9038
查看次数

添加公共变量时崩溃

我有一个相当大的c ++程序,包括一个类"字符".在"Character.h"中,首先声明struct CharacterSettings,然后声明Character类(包括它们的构造函数).

字符具有(其中包括)CharacterSettings*设置和Point pos.CharacterSettings有一个Point preferredVelocity.

这很好用.

但是,当我向Character添加任何公共变量时,程序在我调用时会崩溃:

drawLine(character.pos, character.pos+character.settings->preferredVelocity, character.radius/3.0, 128, 80, 0);
Run Code Online (Sandbox Code Playgroud)

该程序在此行崩溃:

Point operator + (const Point &p2) const
    { return Point(x + p2.x, y + p2.y); }
Run Code Online (Sandbox Code Playgroud)

我假设它正在尝试做character.pos + character.settings-> preferredVelocity.我得到的错误信息是

Unhandled exception at 0x004bc4fc in ECMCrowdSimulation.exe: 0xC0000005: Access violation reading location 0x7f80000f.
Run Code Online (Sandbox Code Playgroud)

当我看到它时,p2.x和p2.y是未定义的.没有额外的变量,他们不是.我完全不知道发生了什么,如何开始调试或者需要哪些信息来帮助我!任何帮助将不胜感激!

编辑:这里至少是Character.h文件!

#pragma once

/* 
 * ECM navigation mesh / crowd simulation software
 * (c) Roland Geraerts and Wouter van Toll, Utrecht University.  
 * ---
 * Character: A single moving character in the …
Run Code Online (Sandbox Code Playgroud)

c++ crash variables

5
推荐指数
1
解决办法
1785
查看次数

标签 统计

c++ ×1

crash ×1

math ×1

trigonometry ×1

variables ×1