标签: projection

基本渲染3D透视投影到2D屏幕上的相机(没有opengl)

假设我有一个如下所示的数据结构:

Camera {
   double x, y, z

   /** ideally the camera angle is positioned to aim at the 0,0,0 point */
   double angleX, angleY, angleZ;
}

SomePointIn3DSpace {
   double x, y, z
}

ScreenData {
   /** Convert from some point 3d space to 2d space, end up with x, y */
   int x_screenPositionOfPt, y_screenPositionOfPt

   double zFar = 100;

   int width=640, height=480
}
Run Code Online (Sandbox Code Playgroud)

...

没有屏幕剪辑或其他任何东西,我如何在空间中给出一些3d点的情况下计算某个点的屏幕x,y位置.我想将这个3d点投影到2d屏幕上.

Camera.x = 0
Camera.y = 10;
Camera.z = -10;


/** ideally, I want the camera to …
Run Code Online (Sandbox Code Playgroud)

c# java math 3d projection

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

Hibernate查询示例和预测

简而言之:hibernate不支持投影和查询示例?我发现这篇文章:

代码是这样的:

User usr = new User();
usr.setCity = 'TEST';
getCurrentSession().createCriteria(User.class)
.setProjection( Projections.distinct( Projections.projectionList()
.add( Projections.property("name"), "name")
.add( Projections.property("city"), "city")))
.add( Example.create(usr))
Run Code Online (Sandbox Code Playgroud)

就像另一张海报所说的那样,生成的sql继续有一个where类引用y0_ =?而不是this_.city.

我已经尝试了几种方法,并搜索了问题跟踪器,但没有发现任何相关信息.

我甚至尝试使用Projection别名和变形金刚,但它不起作用:

User usr = new User();
usr.setCity = 'TEST';
getCurrentSession().createCriteria(User.class)
.setProjection( Projections.distinct( Projections.projectionList()
.add( Projections.property("name"), "name")
.add( Projections.property("city"), "city")))
.add( Example.create(usr)).setResultTransformer(Transformers.aliasToBean(User.class));
Run Code Online (Sandbox Code Playgroud)

有没有人用例子进行投影和查询?

java hibernate criteria projection

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

Spring Data JPA Projection从DB中选择了字段

我正在测试Spring Data 1.10.4.RELEASE,遵循Spring Data Docs中的示例http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections

我注意到一些问题,我有两个问题.

首先让我假设我有这两个实体:

@Entity
public class Person {

  @Id @GeneratedValue
  private Long id;
  private String firstName, lastName;

  @OneToOne
  private Address address;
}

@Entity
public class Address {

  @Id @GeneratedValue
  private Long id;
  private String street, state, country;
}
Run Code Online (Sandbox Code Playgroud)
  • 问题1:

对于以下预测:

interface PersonLimited {  

  String getFirstName(); 

  AddressLimited getAddress();
}

interface AddressLimited {  

  String getCountry(); 
}
Run Code Online (Sandbox Code Playgroud)

当我运行findPersonByFirstNameProjectedForLimitedData时

interface PersonRepository extends CrudRepository<Person, Long> {

  @Query("select p from Person p where p.firstName = ?1")
  PersonLimited findPersonByFirstNameProjectedForLimitedData(String firstName);
} …
Run Code Online (Sandbox Code Playgroud)

java projection spring-data spring-data-jpa

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

如何将QGraphicsScene/View设置为特定的坐标系

我想在多边形中绘制多边形QGraphicsScene但多边形具有纬度/经度位置.在一个equirectangular投影中,坐标来自:

                       ^
                      90
                       |
                       |
-180----------------------------------->180
                       |
                       |
                     -90
Run Code Online (Sandbox Code Playgroud)

如何设置QGraphicsScene/ QGraphicsView到这样的投影?

非常感谢,

卡洛斯.

qt projection qgraphicsview qgraphicsscene

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

如何从参数列表中推导出函数对象的返回类型?

我正在尝试编写一个可以将a vector<T>转换为a 的投影函数vector<R>.这是一个例子:

auto v = std::vector<int> {1, 2, 3, 4};
auto r1 = select(v, [](int e){return e*e; }); // {1, 4, 9, 16}
auto r2 = select(v, [](int e){return std::to_string(e); }); // {"1", "2", "3", "4"}
Run Code Online (Sandbox Code Playgroud)

第一次尝试:

template<typename T, typename R>
std::vector<R> select(std::vector<T> const & c, std::function<R(T)> s)
{
   std::vector<R> v;
   std::transform(std::begin(c), std::end(c), std::back_inserter(v), s);
   return v;
}
Run Code Online (Sandbox Code Playgroud)

但对于

auto r1 = select(v, [](int e){return e*e; });
Run Code Online (Sandbox Code Playgroud)

我明白了:

错误C2660:'select':函数不带2个参数

我必须明确地打电话select<int,int>去工作.我不喜欢这样,因为类型是多余的.

auto r1 = select<int, …
Run Code Online (Sandbox Code Playgroud)

c++ templates projection visual-c++ visual-c++-2013

20
推荐指数
2
解决办法
8272
查看次数

如何构建透视投影矩阵(无API)

我开发了一个简单的3D引擎(没有使用API​​),成功地将我的场景转换为世界和视图空间,但是使用透视投影矩阵(OpenGL样式)无法投影我的场景(从视图空间).我不确定fov,近和远的值,我得到的场景是扭曲的.我希望有人能指导我如何使用示例代码正确构建和使用透视投影矩阵.在此先感谢您的帮助.

矩阵构建:

double f = 1 / Math.Tan(fovy / 2);
return new double[,] { 

    { f / Aspect, 0, 0, 0 },
    { 0, f, 0, 0 },
    { 0, 0, (Far + Near) / (Near - Far),  (2 * Far * Near) / (Near - Far) }, 
    { 0, 0, -1, 0 } 
};
Run Code Online (Sandbox Code Playgroud)

矩阵使用:

foreach (Point P in T.Points)
{     
    .
    .     // Transforming the point to homogen point matrix, to world space, and to view space (works …
Run Code Online (Sandbox Code Playgroud)

math 3d graphics transformation projection

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

在JPA 2中使用预测

我需要转换Hibernate条件查询,如下所示

curList = session.createCriteria(Islem.class)
                    .createAlias("workingDay", "d")
                    .setProjection(Projections.sum("amount"))
                    .add(Restrictions.eq("currency", CURRENCY))
                    .add(Restrictions.eq("product", product))
                    .add(Restrictions.ne("status", INACTIVE))
                    .add(Restrictions.eq("d.status", ACTIVE))
                    .getResultList();
Run Code Online (Sandbox Code Playgroud)

然而在JPA(2)中,我不知道如何实现投影 - 在这种情况下 - 总和.奇怪的是,Hibernate和JPA(甚至是Hibernate JPA 2)在标准查询中存在巨大差异.

我开始

CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Islem> cq = cb.createQuery(Islem.class);
Root<Islem> isr = cq.from(Islem.class);
cq.select(isr).where(cb.equal(isr.get("currency"), CURRENCY), 
                     cb.notEqual(isr.get("status"), INACTIVE),
                     cb.equal(isr.get("product"), product));
Run Code Online (Sandbox Code Playgroud)

但是不知道如何在这里实现投影既不是别名

hibernate projection criteria-api hibernate-criteria jpa-2.0

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

真正的等角投影与opengl

我是使用C++进行OpenGL编程的新手,并不是很擅长数学.是否有一种简单的方法来进行等角投影?

我指的是真正的等距投影,而不是一般的正交投影.

(等距投影仅在单位X,Y和Z矢量的投影长度相等且它们之间的角度恰好为120度时发生.)

代码片段受到高度赞赏..

c++ opengl projection isometric

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

C#:更改数组中每个项的值

我想知道是否有内置的.NET功能来根据提供的委托的结果更改数组中的每个值.例如,如果我有一个数组{1,2,3}和一个返回每个值的平方的委托,我希望能够运行一个接受数组和委托的方法,然后返回{1,4,9}.有这样的事情吗?

c# linq arrays delegates projection

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

OpenGL究竟如何透视地校正线性插值?

如果在OpenGL管道中的光栅化阶段发生线性插值,并且顶点已经转换为屏幕空间,那么用于透视正确插值的深度信息来自何处?

任何人都可以详细描述OpenGL如何从屏幕空间原语转换为具有正确插值的片段?

opengl projection linear-interpolation fragment-shader pixel-shading

17
推荐指数
2
解决办法
7002
查看次数