小编Ezi*_*io_的帖子

如何根据中心单元旋转对象

我有一个网格,我在其中放置一个对象,我想围绕一个固定的单元格(cell3)旋转.该对象包含坐标,如:

activeObject = {
    coords: {
        cell1: {
             x: 0,
             y: 0
        },
        cell2: {
             x: 1,
             y: 1
        },
        cell3: {
             x: 2,
             y: 2
        },
        cell4: {
             x: 2,
             y: 3
        },
        cell5: {
             x: 3,
             y: 3
        },
    }
}
Run Code Online (Sandbox Code Playgroud)

输出:

我想围绕cell3旋转这个对象,例如使用x:2,y:2,而不使用某种(基本)三角函数对每个单元格位置进行硬编码.我意识到我必须检查每个细胞与细胞3的距离以及方向.但是我不知道如何进行计算,因为我对三角学不太了解.新的活动对象将是:

activeObject = {
    coords: {
        cell1: {
             x: 4,
             y: 0
        },
        cell2: {
             x: 4,
             y: 1
        },
        cell3: {
             x: 2,
             y: 2
        },
        cell4: {
             x: 1,
             y: 2
        },
        cell5: { …
Run Code Online (Sandbox Code Playgroud)

javascript

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

Delphi - 如何使用启动/停止功能以毫秒或纳秒为单位制作定时器?

我在Delphi7中寻找一个以毫秒或纳秒为单位的计时器.我必须通过顺序搜索检查三个ISAM文件的速度.第一个ind文件包含50个字符串,如"record_0"到"record_50".第二个 - "record_0"到"record_500",第三个 - "record_0"到"record_5000".我实现了一切,但我不知道如何制作计时器.我正在比较一个字符串与每个ISAM文件中的最后一项.这是我的第一个ind文件的代码:

procedure TForm1.Button1Click(Sender: TObject);
  var i:integer;
  var content : String[20];
  var indexCounter:integer;
  var keyword:string;
begin
  //First ISAM file
  AssignFile(indF1, 'index1.ind');
  ReWrite(indF1);
  Reset(indF1);
  for i:=0 to 49 do begin
    content := 'record_';
    content := content + IntToStr(i+1);
    index1.index1 := content;
    index1.position1 := FileSize(indF1);
    Seek(indF1, FileSize(indF1));
    write(indF1, index1);
  end;
  CloseFile(indF1);
  Label12.Caption := FileSizeStr('index1.ind');

  //Sequential search in first ind file
  Reset(indF1);
  keyword := 'record_50';
  indexCounter := 0;
  //start timer
  while not Eof(indF1) do begin
    Seek(indF1, indexCounter);
    Read(indF1, Index1);
    if …
Run Code Online (Sandbox Code Playgroud)

delphi timer while-loop milliseconds

3
推荐指数
2
解决办法
1万
查看次数

用C/C++绘制3D球体

我正在寻找一种算法,可以在小分辨率上绘制漂亮的3D球体.我找到了Bresenham的圆形算法,但是它用于2D绘图.我只需要球体边框(我不需要它填充).我也搜索了问题的解决方案,但我没有找到任何东西.这篇文章没有帮助(什么是强力算法?).我不能使用任何OpenGL库,我需要vanilla C/C++解决方案.先感谢您.

c graphics voxel

3
推荐指数
3
解决办法
1万
查看次数

http_only cookie会与AJAX一起发送吗?

我找到了这个链接

但在最下方则说此信息可能不再是最新的。 所以我的问题是,将使用AJAX发送http_only cookie吗?可以通过AJAX响应设置http_only cookie吗?

编辑1:假设有一个用户登录到系统。他的会话开始,并且设置了http_only cookie。他尝试通过AJAX获取朋友列表并发送JSON。发出AJAX请求时,我是否需要特别说明要发送或不发送Cookie?默认情况下,每个请求都会将cookie发送到服务器吗?响应会发回Cookie吗(假设我正在更新用户的上次活动时间)?

javascript php cookies ajax httponly

2
推荐指数
1
解决办法
2296
查看次数

JavaScript OOP错误_this值

我们假设我们有以下代码:

var MyClass = (function(){
    var _this;

    function MyClass(inputVal){
        _this = this;
        this.value = inputVal;
    }

    MyClass.prototype.getValue = function(){
        return this.value;
    }

    MyClass.prototype.getValue2 = function(){
        return _this.value;
    }

    return MyClass;
})();
Run Code Online (Sandbox Code Playgroud)

让我们做两个类的实例:

var instance1 = new MyClass(10);
var instance2 = new MyClass(20);
Run Code Online (Sandbox Code Playgroud)

现在,如果我们使用console.log()我们看到的值:

instance1.getValue();   // 10
instance1.getValue2();  // 20
Run Code Online (Sandbox Code Playgroud)

var MyClass = (function(){
    var _this;

    function MyClass(inputVal){
        _this = this;
        this.value = inputVal;
    }

    MyClass.prototype.getValue = function(){
        return this.value;
    }

    MyClass.prototype.getValue2 = function(){
        return _this.value;
    }

    return MyClass;
})();


var …
Run Code Online (Sandbox Code Playgroud)

javascript oop this self

2
推荐指数
1
解决办法
76
查看次数

使用正弦或余弦函数在C/C++中进行3D烟花效果

我想在C中实现烟花效果.我有一个尺寸为10x10x10的立方体.火箭从地面开始,当它到达8楼时,它会爆炸.这是我不能做的 - 爆炸.如何使用正弦或余弦函数实现此功能?在此输入图像描述

一只忙碌的猫

所以在点(5,0,7)//(x,y,z)//火箭飞向空中

for (j=0; j<9; j++) {
    setpoint(x, y, j);
    delay(100);
    clean();  //clears everything
}
Run Code Online (Sandbox Code Playgroud)

这就是制造爆炸的重点.如何实现这一目标?它也可以在随机位置闪烁.提前致谢.

c c++ animation trigonometry

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