我知道将一个正方形转换为一个正方形是一个线性变换,并且可以使用投影矩阵来完成,但我在确定如何构造矩阵时遇到了一些麻烦.
使用投影矩阵进行平移,缩放,旋转和剪切是很简单的.是否有一个简单的投影矩阵将一个方形转换为一个梯形?
我有问题或者好,我不知道如何将x,y,z值转换为3d点到2d点,我必须绘制投影,其中我有x,y,z值的点,但我不知道如何将它们转换为2d,这样我就可以将它们移动到我的轴上.
我一直在环顾wiki和google,但是我不太确定我应该使用哪些矩阵变换来获得想要的结果.
我正在用Java编写我自己的软件光栅化器,我遇到了一些问题...请看一下示例图片,请:
此示例仅在平面上绘制简单的方形网格.一切正常,直到我移动相机足够接近某些点移动它.之后,正如您所看到的那样,它们不再正确投影(垂直线 - 应该在摄像机后面的点投影在屏幕顶部).
我的转换矩阵和向量与DirectX使用的相同(PerspectiveFovLH用于投影,LookAtLH用于相机).
我正在使用以下转换方法来投射3D点:
之后,使用以下方法将点转换为屏幕:
// 'vector' is input vector in projection space
// projection to screen
double vX = vector.x / vector.z;
double vY = vector.y / vector.z;
//translate
//surfaceW is width and surfaceH is height of the rendering window.
vX = (( vX + 1.0f) / 2.0f) * surfaceW;
vY = ((-vY + 1.0f) / 2.0f) * surfaceH;
return new Vector3(vX, vY, vector.z);
Run Code Online (Sandbox Code Playgroud)正如我之前所说,它可以正常工作,直到点移动到相机后面.事实上,我可以弄清楚当点位于相机后面时(通过在最终变换后测试它的Z值),但由于我正在绘制线条和其他基于线的对象,我不能只是跳过这一点.
然后我尝试根据MSDN上的Direct3D Transformation Pipeline文章设置我的转换管道.
不幸的是,我也没有任何运气(相同的结果),所以任何帮助都会受到高度赞赏,因为我有点卡在这一点上.
谢谢.
最诚挚的问候,Alex
我有grails条件构建器的问题,我想对与父表示例一对多关系的表上的列进行投影:
Car.createCriteria() {
projections {
property('name')
property('wheels.name')// ????
}
join 'wheels'
//or wheels {} ???
}
Run Code Online (Sandbox Code Playgroud)
或类似的东西存在?我认为这是别名的基本问题
我对透视投影感到困惑.
这是令我困惑的场景.我的frustrum的前平面基本上位于正z轴,背平面位于负轴,并沿着正z轴旋转大约几度.
现在,每当我通过示例时,我都会看到近平面和远平面都存在于负z轴上.
在这种情况下我的方法基本上是这样的:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustrum(-xval,+xval,-yval,+yval,-10,+10);
gluLookAt(); // some point lying on this axis of symmetry about the point
glMatrixMode(GL_MODELVIEW);
Run Code Online (Sandbox Code Playgroud)
所以,在上面的例子中,对于zie的负值和正值,我应该期待的行为是什么,在这种情况下为-10到+10.
我正在关注自动增量字段的Slick文档示例,我在创建映射投影时遇到了麻烦......好吧,只有一列.
case class UserRole(id: Option[Int], role: String)
object UserRoles extends Table[UserRole]("userRole") {
def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
def role = column[String]("ROLE")
// ...
def * = id.? ~ role <> (UserRole, UserRole.unapply _)
// NEXT LINE ERRORS OUT
def forInsert = role <> ({t => UserRole(None, t._1)}, {(r: UserRole) => Some((r.role))}) returning id
}
Run Code Online (Sandbox Code Playgroud)
错误是"value <>不是scala.slick.lifted.Column [String]"的成员
我还认为设计我的架构更有效:
case class UserRole(role: String)
object UserRoles extends Table[UserRole]("userRole") {
def role = column[Int]("ROLE", O.PrimaryKey)
// …
Run Code Online (Sandbox Code Playgroud) 我正在使用Spring Data REST 2.1.4.RELEASE.
我建立
Booking
,CrudRepository
)命名BookingRepository
BookingDetails
(带有加注解的@Projection(name="details", types = Booking.class)
用于返回它的一些链接的实体的)分解,例如Resource
,Activity
,Applicant
等.客户端获取所有预订,.../rest/bookings
JSON响应包括链接实体的链接.如果添加,?projection=details
则链接的实体将被展开并返回.这很棒.
现在我将这个自定义方法添加到存储库:
List<Booking> findByApplicant(@Param("applicant") Person applicant);
Run Code Online (Sandbox Code Playgroud)
当客户端调用它时.../rest/bookings/search/findByApplicant?applicant=5
,似乎无法请求details
投影.以下尝试被忽略:
&projection=details
到查询字符串使方法始终返回BookingDetails
:
List<BookingDetails> findByApplicant(@Param("applicant") Person applicant);
Run Code Online (Sandbox Code Playgroud)总而言之,自定义搜索方法(findBy*
)永远不会返回投影.除非您使用注释存储库@RepositoryRestResource(excerptProjection = BookingDetails.class)
,但这会导致一些问题,首先客户端必须始终使用相同的投影.我们如何允许用户也使用findBy*
方法投影?
这样的事情可能吗?
我想将一个"hasfocus"变量从cjc-box传递到ng-content属性到cjc-input组件.
app.component.html
<div cjc-box><div cjc-input></div></div>
Run Code Online (Sandbox Code Playgroud)
CIC-box.component.html
<div class="cjc-box">
<div><ng-content hasfocus="focus"></ng-content></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CIC-input.component.html
<input class="cjc-input" type="text" focus="{{hasfocus}}" />
Run Code Online (Sandbox Code Playgroud)
这对于ng2中的预测是否可能?
我在Spring Data JPA中实现投影很困难:
2017-10-19 11:31:33.968 ERROR 4272 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Projection type must be an interface!; nested exception is java.lang.IllegalArgumentException: Projection type must be an interface!] with root cause
java.lang.IllegalArgumentException: Projection type must be an interface!
at org.springframework.util.Assert.isTrue(Assert.java:92) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]
at org.springframework.data.projection.ProxyProjectionFactory.createProjection(ProxyProjectionFactory.java:110) ~[spring-data-commons-1.13.7.RELEASE.jar:na]
at org.springframework.data.projection.SpelAwareProxyProjectionFactory.createProjection(SpelAwareProxyProjectionFactory.java:42) ~[spring-data-commons-1.13.7.RELEASE.jar:na]
at th.co.geniustree.springdata.jpa.repository.support.JpaSpecificationExecutorWithProjectionImpl.lambda$readPageWithProjection$1(JpaSpecificationExecutorWithProjectionImpl.java:77) ~[specification-with-projections-1.0.5.jar:1.0.5]
at org.springframework.data.domain.Chunk.getConvertedContent(Chunk.java:168) ~[spring-data-commons-1.13.7.RELEASE.jar:na]
at org.springframework.data.domain.PageImpl.map(PageImpl.java:104) ~[spring-data-commons-1.13.7.RELEASE.jar:na]
at th.co.geniustree.springdata.jpa.repository.support.JpaSpecificationExecutorWithProjectionImpl.readPageWithProjection(JpaSpecificationExecutorWithProjectionImpl.java:77) ~[specification-with-projections-1.0.5.jar:1.0.5]
at th.co.geniustree.springdata.jpa.repository.support.JpaSpecificationExecutorWithProjectionImpl.findAll(JpaSpecificationExecutorWithProjectionImpl.java:49) ~[specification-with-projections-1.0.5.jar:1.0.5]
at …
Run Code Online (Sandbox Code Playgroud) 考虑以下用于hibernate 的JAVA 模型:
@Entity
@Table
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long id;
@Column
public String firstName;
@Column
public String lastName;
@Column
public Boolean active;
}
Run Code Online (Sandbox Code Playgroud)
以及以下 API 序列化模型(使用spring boot rest 控制器):
public class PersonVO {
public Long id;
public String fullName;
}
Run Code Online (Sandbox Code Playgroud)
我想要的是:
在C# .NET 中,我可以像这样:
IQueryable<Person> personsQuery = entityFrameworkDbContext.Persons;
// FIRST POINT - Here i could make some predefined filtering like 'only active', …
Run Code Online (Sandbox Code Playgroud) projection ×10
perspective ×3
java ×2
matrix ×2
spring ×2
3d ×1
alias ×1
angular ×1
annotations ×1
camera ×1
criteria-api ×1
geometry ×1
grails ×1
graph ×1
hibernate ×1
java-stream ×1
math ×1
opengl ×1
querydsl ×1
rest ×1
scala ×1
slick ×1
transform ×1