如何在 3D 空间中围绕 x 轴旋转正方形

2023-12-12

所以我一直在尝试学习 3D 渲染是如何工作的。我尝试编写一个脚本,目标是在 3D 空间中旋转平面(2D)正方形。我首先在标准化空间 (-1, 1) 中定义一个正方形。请注意,只有 x 和 y 被标准化。

class Vec3:
    #  3D VECTOR
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

s = 1
p1 = Vec3(-s, -s, -s) 
p2 = Vec3(s, -s, -s)
p3 = Vec3(s, s, -s)
p4 = Vec3(-s, s, -s)

然后将这些点翻译到屏幕上:

p1.z += 6
p2.z += 6
p3.z += 6
p4.z += 6

此后的所有事情都在应用程序循环内完成。我使用以下函数将点缩放到屏幕上并应用投影:

class Transform:
    # IT TRANSFORMS THE X AND Y FROM NORMALISED SPACE TO SCREEN SPACE WITH PROJECTION APPLIED 
    def worldSpaceTransform(self, vec3, w, h):
        if vec3.z == 0:
            vec3.z = 0.001
        zInverse = 1/ vec3.z
        xTransformed = ((vec3.x * zInverse) + 1) * (w/2)
        yTransformed = ((-vec3.y * zInverse) + 1) * (h/2)
        xTransformed = str(xTransformed)[:6]
        yTransformed = str(yTransformed)[:6]
        return Vec2(float(xTransformed), float(yTransformed))

像这样:

# TRANSLATING THE SQUARE SHEET INTO THE SCREEN SPACE
    point1 = transform.worldSpaceTransform(p1, SCREENWIDTH, SCREENHEIGHT)
    point2 = transform.worldSpaceTransform(p2, SCREENWIDTH, SCREENHEIGHT)
    point3 = transform.worldSpaceTransform(p3, SCREENWIDTH, SCREENHEIGHT)
    point4 = transform.worldSpaceTransform(p4, SCREENWIDTH, SCREENHEIGHT)

并得出要点:

# STORING THE POINTS TO A TUPLE SO IT CAN BE DRAWN USING pygame.draw.lines
    points = ((point1.x, point1.y), (point2.x, point2.y),
              (point2.x, point2.y), (point3.x, point3.y),
              (point3.x, point3.y), (point4.x, point4.y),
              (point4.x, point4.y), (point1.x, point1.y))
    pygame.draw.lines(D, (0, 0, 0), False, points)

到目前为止,一切都有效(我认为),因为它画了一个正方形,正如它应该的那样。

现在轮换。我尝试了所有轴的旋转,但没有一个起作用,但为了具体起见,我将讨论 x 轴。下面是轮换课。我从维基百科复制了旋转矩阵。我不完全确定它们是如何工作的,所以我也不知道它是否与我上面描述的系统兼容。

def multVecMatrix(vec3, mat3):
    # MULTIPLIES A Vec3 OBJECT WITH Mat3 OBJECT AND RETURNS A NEW Vec3  ? 
    x = vec3.x * mat3.matrix[0][0] + vec3.y * mat3.matrix[0][1] + vec3.z * mat3.matrix[0][2]
    y = vec3.x * mat3.matrix[1][0] + vec3.y * mat3.matrix[1][1] + vec3.z * mat3.matrix[1][2]
    z = vec3.x * mat3.matrix[2][0] + vec3.y * mat3.matrix[2][1] + vec3.z * mat3.matrix[2][2]
    return Vec3(x, y, z)

class Rotation:
    def rotateX(self, theta):
        # ROTATION MATRIX IN X AXIS ??
        sinTheta = sin(theta)
        cosTheta = cos(theta)
        m = Mat3()
        m.matrix = [[1, 0,         0],
                    [0, cosTheta,  sinTheta],
                    [0, -sinTheta, cosTheta]]
        return m

    def rotate(self, vec3, theta, axis=None):
        # ROTATES A Vec3 BY GIVEN THETA AND AXIS ??
        if axis == "x":
            return multVecMatrix(vec3, self.rotateX(theta))
        if axis == "y":
            return multVecMatrix(vec3, self.rotateY(theta))
        if axis == "z":
            return multVecMatrix(vec3, self.rotateZ(theta)) 

在将屏幕填充为白色之后以及将点从标准化空间缩放到屏幕空间之前,它是这样调用的。

    # screen is filled with white color
    # ROTATING THE POINTS AROUND X AXIS ?????

    p1.x = rotation.rotate(p1, thetax, axis='x').x
    p1.y = rotation.rotate(p1, thetay, axis='x').y
    p1.z = rotation.rotate(p1, thetax, axis='x').z

    p2.x = rotation.rotate(p2, thetax, axis='x').x
    p2.y = rotation.rotate(p2, thetay, axis='x').y
    p2.z = rotation.rotate(p2, thetax, axis='x').z

    p3.x = rotation.rotate(p3, thetax, axis='x').x
    p3.y = rotation.rotate(p3, thetay, axis='x').y
    p3.z = rotation.rotate(p3, thetax, axis='x').z

    p4.x = rotation.rotate(p4, thetax, axis='x').x
    p4.y = rotation.rotate(p4, thetay, axis='x').y
    p4.z = rotation.rotate(p4, thetax, axis='x').z
    
    # then the points are translated into world space

应用旋转后,看起来它正在移动并绕 x 轴旋转,但没有旋转。我希望它在旋转的同时保持在原来的位置。我究竟做错了什么?

完整的复制粘贴代码供参考:

import pygame
from math import sin, cos, radians
pygame.init()

### PYGAME STUFF ######################################

SCREENWIDTH = 600
SCREENHEIGHT = 600
D = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT))
pygame.display.set_caption("PRESS SPACE TO ROTATE AROUND X")

######### MATH FUNCTIONS AND CLASSES ####################

class Mat3:
    # 3X3 MATRIX INITIALIZED WITH ALL 0's
    def __init__(self):
        self.matrix = [[0 for i in range(3)],
                      [0 for i in range(3)],
                      [0 for i in range(3)]]

class Vec2:
    # 2D VECTOR
    def __init__(self, x, y):
        self.x = x
        self.y = y

class Vec3:
    #  3D VECTOR
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

def multVecMatrix(vec3, mat3):
    # MULTIPLIES A Vec3 OBJECT WITH Mat3 OBJECT AND RETURNS A NEW Vec3 
    x = vec3.x * mat3.matrix[0][0] + vec3.y * mat3.matrix[0][1] + vec3.z * mat3.matrix[0][2]
    y = vec3.x * mat3.matrix[1][0] + vec3.y * mat3.matrix[1][1] + vec3.z * mat3.matrix[1][2]
    z = vec3.x * mat3.matrix[2][0] + vec3.y * mat3.matrix[2][1] + vec3.z * mat3.matrix[1][2]
    return Vec3(x, y, z)

class Transform:
    # IT TRANSFORMS THE X AND Y FROM NORMALIZED SPACE TO SCREEN SPACE WITH PROJECTION APPLIED
    def worldSpaceTransform(self, vec3, w, h):
        if vec3.z == 0:
            vec3.z = 0.001
        zInverse = 1/ vec3.z
        xTransformed = ((vec3.x * zInverse) + 1) * (w/2)
        yTransformed = ((-vec3.y * zInverse) + 1) * (h/2)
        xTransformed = str(xTransformed)[:6]
        yTransformed = str(yTransformed)[:6]
        return Vec2(float(xTransformed), float(yTransformed))

class Rotation:
    def rotateX(self, theta):
        # ROTATION MATRIX IN X AXIS
        sinTheta = sin(theta)
        cosTheta = cos(theta)
        m = Mat3()
        m.matrix = [[1, 0,         0],
                    [0, cosTheta,  sinTheta],
                    [0, -sinTheta, cosTheta]]
        return m

    def rotate(self, vec3, theta, axis=None):
        # ROTATES A Vec3 BY GIVEN THETA AND AXIS
        if axis == "x":
            return multVecMatrix(vec3, self.rotateX(theta))
        if axis == "y":
            return multVecMatrix(vec3, self.rotateY(theta))
        if axis == "z":
            return multVecMatrix(vec3, self.rotateZ(theta))

transform = Transform()
rotation = Rotation()


# ASSIGNING 4 Vec3's FOR 4 SIDES OF SQUARE IN NORMALIZED SPACE
s = 1
p1 = Vec3(-s, -s, -s) 
p2 = Vec3(s, -s, -s)
p3 = Vec3(s, s, -s)
p4 = Vec3(-s, s, -s)

# TRANSLATING THE POINTS OF THE CUBE A LITTLE BIT INTO THE SCREEN
p1.z += 6
p2.z += 6
p3.z += 6
p4.z += 6

# ASSIGNING THE ROTATION ANGLES
thetax = 0

# APPLICATION LOOP
while True:
    pygame.event.get()
    D.fill((255, 255, 255))


    # ROTATING THE POINTS AROUND X AXIS

    p1.x = rotation.rotate(p1, thetax, axis='x').x
    p1.y = rotation.rotate(p1, thetax, axis='x').y
    p1.z = rotation.rotate(p1, thetax, axis='x').z

    p2.x = rotation.rotate(p2, thetax, axis='x').x
    p2.y = rotation.rotate(p2, thetax, axis='x').y
    p2.z = rotation.rotate(p2, thetax, axis='x').z

    p3.x = rotation.rotate(p3, thetax, axis='x').x
    p3.y = rotation.rotate(p3, thetax, axis='x').y
    p3.z = rotation.rotate(p3, thetax, axis='x').z

    p4.x = rotation.rotate(p4, thetax, axis='x').x
    p4.y = rotation.rotate(p4, thetax, axis='x').y
    p4.z = rotation.rotate(p4, thetax, axis='x').z
    

    # TRANSLATING THE SQUARE SHEET INTO THE SCREEN SPACE
    point1 = transform.worldSpaceTransform(p1, SCREENWIDTH, SCREENHEIGHT)
    point2 = transform.worldSpaceTransform(p2, SCREENWIDTH, SCREENHEIGHT)
    point3 = transform.worldSpaceTransform(p3, SCREENWIDTH, SCREENHEIGHT)
    point4 = transform.worldSpaceTransform(p4, SCREENWIDTH, SCREENHEIGHT)

    # STORING THE POINTS TO A TUPLE SO IT CAN BE DRAWN USING pygame.draw.lines
    points = ((point1.x, point1.y), (point2.x, point2.y),
              (point2.x, point2.y), (point3.x, point3.y),
              (point3.x, point3.y), (point4.x, point4.y),
              (point4.x, point4.y), (point1.x, point1.y))

    
    keys = pygame.key.get_pressed()
    # ROTATE X ?
    if keys[pygame.K_SPACE]:
        thetax -= 0.005

    pygame.draw.lines(D, (0, 0, 0), False, points)
    
    pygame.display.flip()

没有必要单独旋转向量的每个分量。如果你这样做

p1.x = rotation.rotate(p1, thetax, axis='x').x

那么x的组成部分p1已经改变并且p1传递给下一条指令的内容是不同的

p1.y = rotation.rotate(p1, thetay, axis='x').y

将整个顶点旋转一次就足够了:

p1 = rotation.rotate(p1, thetax, axis='x')  
p2 = rotation.rotate(p2, thetax, axis='x')
p3 = rotation.rotate(p3, thetax, axis='x')
p4 = rotation.rotate(p4, thetax, axis='x')

将向量乘以旋转矩阵时,向量将旋转一轮 (0, 0, 0)。旋转后必须进行平移。
Add a +- 操作员Vec3 class:

class Vec3:
    #  3D VECTOR
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z
    def __add__(a, b):
        return Vec3(a.x+b.x, a.y+b.y, a.z+b.z)

永远不要改变原来的顶点坐标p1, p2, p3 and p4。计算旋转,然后计算平移:

# TRANSLATING THE POINTS OF THE CUBE A LITTLE BIT INTO THE SCREEN
#p1.z += 6 <--- DELETE
#p2.z += 6
#p3.z += 6
#p4.z += 6
transVec = Vec3(0, 0, 6)

# [...]

while run:

    # ROTATING THE POINTS AROUND X AXIS
    point1 = rotation.rotate(p1, thetax, axis='x')  
    # [...]

    # TRANSLATING THE POINTS OF THE CUBE A LITTLE BIT INTO THE SCREEN
    point1 = point1 + transVec
    # [...]

    # TRANSLATING THE SQUARE SHEET INTO THE SCREEN SPACE
    point1 = transform.worldSpaceTransform(point1, SCREENWIDTH, SCREENHEIGHT)
    # [...]

我建议在列表中组织顶点坐标:

# ASSIGNING 4 Vec3's FOR 4 SIDES OF SQUARE IN NORMALIZED SPACE
s = 1
modelPoints = [Vec3(-s, -s, -s), Vec3(s, -s, -s), Vec3(s, s, -s), Vec3(-s, s, -s)]

# TRANSLATING THE POINTS OF THE CUBE A LITTLE BIT INTO THE SCREEN
transVec = Vec3(0, 0, 6)

# ASSIGNING THE ROTATION ANGLES
thetax = 0

# APPLICATION LOOP
run = True
while run:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    D.fill((255, 255, 255))

    # ROTATING THE POINTS AROUND X AXIS
    points = [rotation.rotate(pt, thetax, axis='x') for pt in modelPoints]

    # TRANSLATING THE POINTS OF THE CUBE A LITTLE BIT INTO THE SCREEN
    points = [pt + transVec for pt in points]

    # TRANSLATING THE SQUARE SHEET INTO THE SCREEN SPACE
    points = [transform.worldSpaceTransform(pt, SCREENWIDTH, SCREENHEIGHT) for pt in points]

    # STORING THE POINTS TO A TUPLE SO IT CAN BE DRAWN USING pygame.draw.lines
    points = [(pt.x, pt.y) for pt in points]

请参阅完整示例:

import pygame
from math import sin, cos, radians
pygame.init()

### PYGAME STUFF ######################################

SCREENWIDTH = 600
SCREENHEIGHT = 600
D = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT))
pygame.display.set_caption("PRESS SPACE TO ROTATE AROUND X")

######### MATH FUNCTIONS AND CLASSES ####################

class Mat3:
    # 3X3 MATRIX INITIALIZED WITH ALL 0's
    def __init__(self):
        self.matrix = [[0 for i in range(3)],
                      [0 for i in range(3)],
                      [0 for i in range(3)]]

class Vec2:
    # 2D VECTOR
    def __init__(self, x, y):
        self.x = x
        self.y = y

class Vec3:
    #  3D VECTOR
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z
    def __add__(a, b):
        return Vec3(a.x+b.x, a.y+b.y, a.z+b.z)

def multVecMatrix(vec3, mat3):
    # MULTIPLIES A Vec3 OBJECT WITH Mat3 OBJECT AND RETURNS A NEW Vec3 
    x = vec3.x * mat3.matrix[0][0] + vec3.y * mat3.matrix[0][1] + vec3.z * mat3.matrix[0][2]
    y = vec3.x * mat3.matrix[1][0] + vec3.y * mat3.matrix[1][1] + vec3.z * mat3.matrix[1][2]
    z = vec3.x * mat3.matrix[2][0] + vec3.y * mat3.matrix[2][1] + vec3.z * mat3.matrix[2][2]
    return Vec3(x, y, z)

class Transform:
    # IT TRANSFORMS THE X AND Y FROM NORMALIZED SPACE TO SCREEN SPACE WITH PROJECTION APPLIED
    def worldSpaceTransform(self, vec3, w, h):
        if vec3.z == 0:
            vec3.z = 0.001
        zInverse = 1/ vec3.z
        xTransformed = ((vec3.x * zInverse) + 1) * (w/2)
        yTransformed = ((-vec3.y * zInverse) + 1) * (h/2)
        xTransformed = str(xTransformed)[:6]
        yTransformed = str(yTransformed)[:6]
        return Vec2(float(xTransformed), float(yTransformed))

class Rotation:
    def rotateX(self, theta):
        # ROTATION MATRIX IN X AXIS
        sinTheta = sin(theta)
        cosTheta = cos(theta)
        m = Mat3()
        m.matrix = [[1, 0,         0],
                    [0, cosTheta,  sinTheta],
                    [0, -sinTheta, cosTheta]]
        return m

    def rotate(self, vec3, theta, axis=None):
        # ROTATES A Vec3 BY GIVEN THETA AND AXIS
        if axis == "x":
            return multVecMatrix(vec3, self.rotateX(theta))
        if axis == "y":
            return multVecMatrix(vec3, self.rotateY(theta))
        if axis == "z":
            return multVecMatrix(vec3, self.rotateZ(theta))


transform = Transform()
rotation = Rotation()


# ASSIGNING 4 Vec3's FOR 4 SIDES OF SQUARE IN NORMALIZED SPACE
s = 1
modelPoints = [Vec3(-s, -s, -s), Vec3(s, -s, -s), Vec3(s, s, -s), Vec3(-s, s, -s)]

# TRANSLATING THE POINTS OF THE CUBE A LITTLE BIT INTO THE SCREEN
transVec = Vec3(0, 0, 6)

# ASSIGNING THE ROTATION ANGLES
thetax = 0

# APPLICATION LOOP
run = True
while run:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False

    D.fill((255, 255, 255))

    # ROTATING THE POINTS AROUND X AXIS
    points = [rotation.rotate(pt, thetax, axis='x') for pt in modelPoints]

    # TRANSLATING THE POINTS OF THE CUBE A LITTLE BIT INTO THE SCREEN
    points = [pt + transVec for pt in points]

    # TRANSLATING THE SQUARE SHEET INTO THE SCREEN SPACE
    points = [transform.worldSpaceTransform(pt, SCREENWIDTH, SCREENHEIGHT) for pt in points]

    # STORING THE POINTS TO A TUPLE SO IT CAN BE DRAWN USING pygame.draw.lines
    points = [(pt.x, pt.y) for pt in points]
    
    keys = pygame.key.get_pressed()
    # ROTATE X ?
    if keys[pygame.K_SPACE]:
        thetax -= 0.005

    pygame.draw.lines(D, (0, 0, 0), True, points)
    
    pygame.display.flip()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 3D 空间中围绕 x 轴旋转正方形 的相关文章

  • 从数据框中按索引删除行

    我有一个数组wrong indexes train其中包含我想从数据框中删除的索引列表 0 63 151 469 1008 要删除这些索引 我正在尝试这样做 df train drop wrong indexes train 但是 代码失败
  • Python Popen 与 psexec 挂起 - 不良结果

    我对 subprocess Popen 和我认为是管道的问题有疑问 我有以下代码块 从 cli 运行时 100 都不会出现问题 p subprocess Popen psexec serverName get cmd c ver echo
  • 使用 python 进行串行数据记录

    Intro 我需要编写一个小程序来实时读取串行数据并将其写入文本文件 我在读取数据方面取得了一些进展 但尚未成功地将这些信息存储在新文件中 这是我的代码 from future import print function import se
  • 我怎样才能更多地了解Python的内部原理? [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我使用Python编程已经有半年多了 我对Python内部更感兴趣 而不是使用Python开发应用程序
  • pydev 调试器:严重警告:此版本的 python 似乎编译不正确(内部生成的文件名不是绝对的)[重复]

    这个问题在这里已经有答案了 通过运行 from sklearn datasets import fetch california housing import pandas as pd pd set option precision 4 m
  • 填充两个函数之间的区域

    import matplotlib pyplot as plt import numpy as np def domain x np arange 0 10 0 001 f1 lambda x 2 x x 2 0 5 plt plot x
  • 为什么Python的curses中escape键有延迟?

    In the Python curses module I have observed that there is a roughly 1 second delay between pressing the esc key and getc
  • 以同步方式使用 FastAPI,如何获取 POST 请求的原始正文?

    在中使用 FastAPIsync not async模式 我希望能够接收 POST 请求的原始 未更改的正文 我能找到的所有例子都显示async代码 当我以正常同步方式尝试时 request body 显示为协程对象 当我通过发布一些内容来
  • 如何通过在 Python 3.x 上按键来启动和中断循环

    我有这段代码 当按下 P 键时会中断循环 但除非我按下非 P 键 否则循环不会工作 def main openGame while True purchase imageGrab if a sum gt 1200 fleaButton ti
  • TensorFlow的./configure在哪里以及如何启用GPU支持?

    在我的 Ubuntu 上安装 TensorFlow 时 我想将 GPU 与 CUDA 结合使用 但我却停在了这一步官方教程 http www tensorflow org get started os setup md 这到底是哪里 con
  • 使用鼻子获取设置中当前测试的名称

    我目前正在使用鼻子编写一些功能测试 我正在测试的库操作目录结构 为了获得可重现的结果 我存储了一个测试目录结构的模板 并在执行测试之前创建该模板的副本 我在测试中执行此操作 setup功能 这确保了我在测试开始时始终具有明确定义的状态 现在
  • 将 matplotlib 颜色图集中在特定值上

    我正在使用 matplotlib 颜色图 seismic 绘制绘图 并且希望白色以 0 为中心 当我在不进行任何更改的情况下运行脚本时 白色从 0 下降到 10 我尝试设置 vmin 50 vmax 50 但在这种情况下我完全失去了白色 关
  • 如何使用列表作为pandas数据框中的值?

    我有一个数据框 需要列的子集包含具有多个值的条目 下面是一个带有 运行时 列的数据框 其中包含程序在各种条件下的运行时 df condition a runtimes 1 1 5 2 condition b runtimes 0 5 0 7
  • 使用 Firefox 绕过弹出窗口下载文件:Selenium Python

    我正在使用 selenium 和 python 来从中下载某些文件web page http www oceanenergyireland com testfacility corkharbour observations 我之前一直使用设
  • 在 2D 中将一个点旋转另一个点

    我想知道当一个点相对于另一个点旋转一定角度时如何计算出新的坐标 我有一个块箭头 想要将其相对于箭头底部中间的点旋转角度 theta 这是允许我在两个屏幕控件之间绘制多边形所必需的 我无法使用和旋转图像 从我到目前为止所考虑的情况来看 使问题
  • 如何挤出平面 2D 网格并赋予其深度

    我有一组共面 连接的三角形 即二维网格 现在我需要将其在 z 轴上挤出几个单位 网格由一组顶点定义 渲染器通过与三角形数组匹配来理解这些顶点 网格示例 顶点 0 0 0 10 0 0 10 10 0 0 10 0 所以这里我们有一个二维正方
  • 您可以将操作直接应用于map/reduce/filter 中的参数吗?

    map and filter通常可以与列表理解互换 但是reduce并不那么容易被交换map and filter 此外 在某些情况下我仍然更喜欢函数语法 但是 当您需要对参数本身进行操作时 我发现自己正在经历语法体操 最终必须编写整个函数
  • 如何读取Python字节码?

    我很难理解 Python 的字节码及其dis module import dis def func x 1 dis dis func 上述代码在解释器中输入时会产生以下输出 0 LOAD CONST 1 1 3 STORE FAST 0 x
  • 检查字典键是否有空值

    我有以下字典 dict1 city name yass region zipcode phone address tehsil planet mars 我正在尝试创建一个基于 dict1 的新字典 但是 它不会包含带有空字符串的键 它不会包
  • 列表值的意外更改

    这是我的课 class variable object def init self name name alias parents values table name of the variable self name 这是有问题的函数 f

随机推荐

  • 如何通过 IDE(Netbeans、Eclipse)中的 optirun (Bumblebee) 运行使用图形驱动程序的构建?

    有谁知道如何通过在IDE中调用optirun bumblebee 来使eclipse或netbeans使用optimus笔记本电脑中的显卡 以便只需使用IDE中的运行按钮即可在IDE中的显卡中运行程序 以最简单的形式 我只希望 IDE 执行
  • 在 iframe 内使用 angularjs 变量

    所以我想在 iframe src 或 ng src 属性内使用变量 显然 无论我使用什么 我的变量都没有被识别 例如 其中测试只是显示为 test 另外当我使用 sce要将其用作受信任的 url 它不起作用 普通 src 也是如此 有什么我
  • NetUserAdd - 权限问题,参数不正确

    我在用着网络用户添加添加新管理员 但我收到一个我无法弄清楚的错误 失败方法返回的错误是 NET API STATUS 87 PARAM ERR 5 The NET API STATUS有一个价值87这是ERROR INVALID PARAM
  • 为什么我不能使用列表迭代器逻辑比较运算符?

    这是非常基本的 但我在这里找不到类似的问题 我正在尝试使用 list 从不同方向迭代相同的排序 STL 列表 我知道我可以将迭代器与list begin and list end 那么为什么这不起作用呢 list
  • 将项目垂直排列在行/列中,而不是水平排列

    我正在创建一个 html 页面 并希望切换到页面的滚动和浮动 所以在 body 或 div 中我想要一个项目列表 每个项目都应该位于前一个项目的下方 除非触及 div 的末尾 然后它应该位于较高的部分 依此类推 因此 如果要显示的内容太多
  • 在 PHP 会话中存储对象

    PHP 文档说 您不能在会话变量中使用引用 因为没有可行的方法来恢复对另一个变量的引用 这是否意味着我不能拥有类似的东西 session start user new User user gt name blah SESSION user
  • 透明 Bootstrap 导航栏

    我正在开发一个网站 我希望导航 仅主页 是透明的并且图像覆盖全屏 这是我到目前为止所拥有的 导航栏采用这种方式设计 因为其他页面上也是如此 这是我的 HTML div class container fluid div
  • 按方案中对的第二个元素对对列表进行排序

    我在方案中有一个程序 它给我一个对的列表 我需要按对的第二个元素对该列表进行降序排序 像这样 1 1 2 3 3 2 gt 2 3 3 2 1 1 1 1 x 3 2 1 3 1 gt x 3 1 1 2 1 3 1 1 3 3 4 2 2
  • Pyspark - df.cache().count() 需要永远运行

    我正在尝试使用我在网上阅读的计数方法强制对 PySpark 进行热切评估 spark df spark read jdbc url jdbcUrl table pushdown query properties connectionProp
  • 高效批量更新rails数据库

    我正在尝试构建一个 rake 实用程序 它会经常更新我的数据库 这是我到目前为止的代码 namespace utils do utils update ip Downloads the file frim
  • .Net“任何框架”配置

    我用 C NET 2 0 构建了一个程序 该程序在框架 3 0 和 3 5 下也能很好地工作 但如果 NET Framework 4 0是唯一安装的框架 则它不起作用 需要用户安装2 0 我在google中找到了以下配置
  • 堆栈与堆属性的 QT 特定差异?

    通常 在编写 C 代码时 我会始终将对象保留为普通属性 从而利用 RAII 然而 在 QT 中 删除对象的责任可以由析构函数承担QObject 因此 假设我们定义了一些特定的小部件 那么我们有两种可能性 1 使用QT的系统 class Wi
  • 不允许从一个 Google 电子表格访问另一个 Google 电子表格

    我试图通过其他电子表格中的 onEdit 事件为我的 Google 电子表格设置新值 我收到异常 不允许执行操作 我不明白我到底做错了什么 我会很高兴得到你的帮助 因为我只是在 JS Google Docs 脚本中做第一步 function
  • 将函数与 numpy 数组的每个元素积分作为积分极限

    我在 python 中有一个函数 也使用 scipy 和 numpy 定义为 import numpy as np from scipy import integrate LCDMf lambda x 1 0 np sqrt 0 3 1 x
  • 尝试使用 groupby 查找每月 5 个最大值

    我试图显示前三个值nc type每个月 我尝试使用n largest但这并没有按日期完成 原始数据 area nc type occurred date 0 Filling x 12 23 2015 0 00 1 Filling f 12
  • ddply+summary函数列名输入

    我正在尝试使用ddply and summarise一起从plyr包 但在解析不断变化的列名时遇到困难 在我的示例中 我想要一些能够以编程方式在 X1 中解析的东西 而不是在 X1 中硬编码到 ddply 函数中 举例说明 require
  • Android - 无法隐藏进度条

    因此 我检查了其他问题以隐藏进度条 但所有问题似乎都建议做我已经在做的事情 我正在尝试使用 mProductListProgressBar setVisibility View GONE 我找到它 mProductListProgressB
  • Makefile 更新了库依赖项

    我有一个很大的 makefile 它构建几个库 安装它们 然后继续构建链接到这些已安装库的对象 我的麻烦是我想使用 lfoo lbar 作为 g 标志来链接两个已安装的库 但依赖关系变得混乱 如果我更改库 foo 所依赖的标头 42 h 那
  • 查找 python 的安装位置(如果不是默认目录)

    Python 在我的机器上 我只是不知道在哪里 如果我在终端中输入 python 它将打开 Python 2 6 4 这不在它的默认目录中 肯定有一种方法可以从这里找到它的安装位置 sys有一些有用的东西 python Python 2 6
  • 如何在 3D 空间中围绕 x 轴旋转正方形

    所以我一直在尝试学习 3D 渲染是如何工作的 我尝试编写一个脚本 目标是在 3D 空间中旋转平面 2D 正方形 我首先在标准化空间 1 1 中定义一个正方形 请注意 只有 x 和 y 被标准化 class Vec3 3D VECTOR de