public double Magnitude
{
get
{
return Math.Sqrt(this.SumComponentSqrs());
}
set
{
if (value < 0.0)
{
throw new ArgumentOutOfRangeException("value", value, "The magnitude of a Vector3 must be a positive value, (i.e. greater than 0)");
}
if (this == new Vector3(0.0, 0.0, 0.0))
{
throw new ArgumentException("Cannot change the magnitude of Vector3(0,0,0)", "this");
}
this = (Vector3) (this * (value / this.Magnitude));
}这个代码的诡异之处是Magnitude自己给自己赋值了
但是,我看了2天代码,包括子程序和主程序
都没有其他外在程序给Magnitude赋值的语句
例如:object.Magnitude=x
等等诸如语句,什么都没有
难道,Magnitude能自我迭代自己?是错的吧!?
其中this 就是Vector3c#
{
get
{
return Math.Sqrt(this.SumComponentSqrs());
}
set
{
if (value < 0.0)
{
throw new ArgumentOutOfRangeException("value", value, "The magnitude of a Vector3 must be a positive value, (i.e. greater than 0)");
}
if (this == new Vector3(0.0, 0.0, 0.0))
{
throw new ArgumentException("Cannot change the magnitude of Vector3(0,0,0)", "this");
}
this = (Vector3) (this * (value / this.Magnitude));
}这个代码的诡异之处是Magnitude自己给自己赋值了
但是,我看了2天代码,包括子程序和主程序
都没有其他外在程序给Magnitude赋值的语句
例如:object.Magnitude=x
等等诸如语句,什么都没有
难道,Magnitude能自我迭代自己?是错的吧!?
其中this 就是Vector3c#
解决方案 »
- 请教一个关于二次开发的数据库的问题.
- 如何增加一个窗体的复制窗体
- ==很奇怪的问题== 程序偶尔在 Thread.Start() 处卡住
- 弱弱的窗体关闭的问题
- C#关于一个输入字符格式不正确的问题,高手帮帮忙。。
- 各位帮忙看看这个结构问题应该如何解决?
- 什么是“菜谱式的编程任务”
- 为什么我添加了word组件,还是说“找不到命名空间名称word”
- 不解的错误:An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
- 大家来找碴——又是语法错误,在线!!
- 关于流对象的问题
- c# 多线程异步操作Dictionary'
会去访问get,因此那个地方等价于
value / Math.Sqrt(this.SumComponentSqrs()); 如果是迭代调用属性自己反而错了(比如get里访问属性值,set里再给属性本身赋值),死循环,堆栈直接溢出
但是你上面那个不是的,get:每次访问this.Magnitude,都会进行那个运算
你水平真高
简单一句话,让我有点明白了
我在研究下和大家交流
就算错误怎么才能实现迭代呢?