Skyline软件二次开发初级——6如何在WEB页面中的三维地图上进行坐标和方向计算...
1.距离和角度:
<head>
<title>Coordinates 1</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
// defining two coordinates
var coord1 = SGWorld.Creator.CreatePosition(-71.07542, 42.34930, 232.0); // The Hancock building
var coord2 = SGWorld.Creator.CreatePosition(-71.05507, 42.35561, 105.0); // Target building
// Placing some annotation on the terrain
SGWorld.Creator.CreateTextLabel(coord1, "Hancock Building",SGWorld.Creator.CreateLabelStyle());
SGWorld.Creator.CreateTextLabel(coord2, "Building 2",SGWorld.Creator.CreateLabelStyle());
SGWorld.Creator.CreatePolyline(SGWorld.Creator.GeometryCreator.CreateLineStringGeometry([coord1, coord2]), SGWorld.Creator.CreateColor(255, 255, 0), 0, 0, "line");
// Set a good view point for the scene
SGWorld.Navigate.SetPosition(SGWorld.Creator.CreatePosition(-71.07802, 42.33974, 550.0,0, 34, -13));
// Calculating the distance and angles from the Hancock building to building #2
var distance = coord1.DistanceTo(coord2);
var angles = coord1.AimTo(coord2);
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Coordinate sample","",0,0,450,120);
popup.InnerText = "The aerial distance between the roofs of the\r\nHancock building and building #2 is " + Math.floor(distance) + " Meters\r\n\r\n" +
"The aiming angles from the Hancock building to building #2 are:\r\nyaw: " + angles.Yaw.toFixed(5) + " pitch: " + angles.Pitch.toFixed(5);
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
2.位置和方向:
<head>
<title>Coordinates 1</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
function Init()
{
// defining two coordinates
var coord1 = SGWorld.Creator.CreatePosition(-71.07542, 42.34930, 232.0);
var coord2 = SGWorld.Creator.CreatePosition(-71.05507, 42.35561, 105.0);
// Placing some annotation on the terrain
SGWorld.Creator.CreateTextLabel(coord1, "Hancock Building",SGWorld.Creator.CreateLabelStyle());
SGWorld.Creator.CreateTextLabel(coord2, "Building 2",SGWorld.Creator.CreateLabelStyle());
var pos = coord1.AimTo(coord2);
SGWorld.Navigate.SetPosition(pos);
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Coordinate sample");
popup.innerText = "This sample shows how to place the camera at a specific position\r\nwhile aiming it to a desired point of interest";
popup.align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
3.移动指向位置:
<head>
<title>Coordinates 1</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
var coord1, coord2, pos, distance;
var time;
function Init()
{
SGWorld.AttachEvent("OnFrame", onFrame);
time = new Date().getTime();
// defining two coordinates
coord1 = SGWorld.Creator.CreatePosition(-71.07542, 42.34930, 232.0);
coord2 = SGWorld.Creator.CreatePosition(-71.05507, 42.35561, 105.0);
// Placing some annotation on the terrain
SGWorld.Creator.CreateTextLabel(coord1, "Hancock Building",SGWorld.Creator.CreateLabelStyle());
SGWorld.Creator.CreateTextLabel(coord2, "Building 2",SGWorld.Creator.CreateLabelStyle());
distance = coord1.DistanceTo(coord2);
pos = coord1.AimTo(coord2);
// Set the start position at the top of the Hancock building
SGWorld.Navigate.SetPosition(pos);
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Coordinate sample");
popup.InnerText = "This sample shows how to move a coordinate toward another coordinate";
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function onFrame()
{
var elapsedTime = (new Date().getTime() - time) / 1000 // elapsed time in seconds
time = new Date().getTime();
pos = pos.MoveToward(coord2, 200*elapsedTime); // 200 meters/sec
var newDist = pos.DistanceTo(coord2);
if (newDist > distance)
{
// Stop condition. if we are here, then we have passed building 2
SGWorld.DetachEvent("OnFrame", onFrame);
return;
}
SGWorld.Navigate.SetPosition(pos);
distance = newDist;
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
4.朝着某个对象移动:
<head>
<title>Coordinates 1</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript">
var popup = null;
var coordHancock, pos;
var time;
function Init()
{
SGWorld.AttachEvent("OnFrame", onFrame);
setTimeout(function () { SGWorld.DetachEvent("OnFrame", onFrame); }, 15000);
time = new Date().getTime();
coordHancock = SGWorld.Creator.CreatePosition(-71.07542, 42.34930, 232.0);
SGWorld.Creator.CreateTextLabel(coordHancock, "Hancock Building",SGWorld.Creator.CreateLabelStyle());
pos = SGWorld.Creator.CreatePosition(-71.10055, 42.31624, 350.0,0, 15.0); // x,y,height,height_type,yaw
SGWorld.Navigate.SetPosition(pos);
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Coordinate sample");
popup.InnerText = "This sample shows how you can move a coordinate in one direction while aiming to another";
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function onFrame()
{
var elapsedTime = (new Date().getTime() - time) / 1000 // elapsed time in seconds
time = new Date().getTime();
pos = pos.Move(400*elapsedTime, 15.0, 0.0).AimTo(coordHancock); // 400 meters/sec
SGWorld.Navigate.SetPosition(pos);
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
5.以上效果叠加:
<head>
<title>Coordinates 5</title>
<object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
<script type="text/javascript" src="abspath.js"></script>
<script type="text/javascript">
var popup = null;
var model = null;
var labelF16 = null;
var yaw = 45.0;
var totalTime = 0;
function Init()
{
SGWorld.AttachEvent("OnFrame", onFrame);
setTimeout(function () { SGWorld.DetachEvent("OnFrame", onFrame); }, 10000); // remove event handler after 10 seconds
time = new Date().getTime();
model = SGWorld.Creator.CreateModel(SGWorld.Creator.CreatePosition(-71.10055, 42.31624, 125.0,0, 28), toAbspath("data/f16.xpc"), 1);
labelF16 = SGWorld.Creator.CreateTextLabel(SGWorld.Creator.CreatePosition(0, 0), "F-16",SGWorld.Creator.CreateLabelStyle());
// Display a message to the user
popup = SGWorld.Creator.CreatePopupMessage("Coordinate sample");
popup.InnerText = "This sample shows how, by manipulating coordinates, you can create a complex scene\r\n" +
"In this sample you can see how to:\r\n" +
"1. Move an object (F16)\r\n" +
"2. Make another object, a label in this case, to follow the first object\r\n" +
"3. Make the camera follow the first object while circling it";
popup.Align = "TopLeft";
SGWorld.Window.ShowPopup(popup);
}
function onFrame() // elapsedTime is the time in seconds elapsed from the previous frame
{
var elapsedTime = (new Date().getTime() - time) / 1000 // elapsedTime is the time in seconds elapsed from the previous frame
time = new Date().getTime();
var modelPos = model.Position;
modelPos.Roll = modelPos.Roll + 4.5;
modelPos = modelPos.Move(700 * elapsedTime, modelPos.Yaw, modelPos.Pitch); // move the object in its current direction at a speed of 700 m/s
if (totalTime > 6)
modelPos.Pitch += 20*elapsedTime; // increase pitch by 20 degree per sec
model.Position = modelPos;
// Make the label object to be positioned 40 meters above (pitch = 90) the first object
labelF16.Position = modelPos.Move(40.0, 0.0, 90.0);
// Move the camera in relation to the first object while looking at it.
yaw += 40.0*elapsedTime; // increase yaw by 40 degree per sec
var cameraPos = modelPos.Move(700, yaw, 5).AimTo(modelPos);
cameraPos.Roll = 0; // plane is rolling, but we do not want the camera to use this roll, so we zero it.
SGWorld.Navigate.SetPosition(cameraPos);
totalTime += elapsedTime;
}
function Uninit()
{
if(SGWorld.Project.Name == "")
return;
if(popup)
SGWorld.Window.RemovePopup(popup);
}
</script>
</head>
<body onload="Init();" onunload="Uninit()">
</body>
</html>
转载于:https://www.cnblogs.com/yitianhe/archive/2012/09/24/2699632.html
Skyline软件二次开发初级——6如何在WEB页面中的三维地图上进行坐标和方向计算...相关推荐
- c# 无法加载oraops.dll_Robotstudio软件二次开发:基于C#语言的Smart组件开发基础
Robotstudio软件除了支持Add-Ins插件的二次开发以外,还支持Smart组件的二次开发.开发语言同样是基于.NET框架的C#语言或VB语言.Smart组件是Robotstudio软件中实现 ...
- 欢迎光临CAX软件二次开发开源社区!
欢迎光临CAX软件二次开发开源社区! http://uucax.uueasy.com 转载于:https://www.cnblogs.com/uucax/archive/2011/02/20/1959 ...
- vb杨辉三角代码编写_「二次开发」——基于VB.NET的NX UG软件二次开发基础
前几期中为大家介绍了CATIA软件.AutoCAD软件基于VB.NET的二次开发,本期再来为大家介绍一下NX UG软件基于VB.NET的二次开发. NX UG软件版本:NX 12.0.0.27 开发软 ...
- 金蝶erp系统服务器端,金蝶ERP软件二次开发.doc
金蝶ERP软件二次开发 摘要 企业要提升快速反应的能力,必须建立以信息集中.流程整合.实施控制为核心特点的快速反应体系,有效整合资源,强化基础管理.ERP软件可以帮助企业实现这些目标,但要成功地实施E ...
- Python--中控门禁软件二次开发--引导
Python--中控门禁软件二次开发--引导 说明 : 公司门禁型号是:中控门禁 F7plus ,因为没有安装带遥控开门的,也没有什么感应,当有访客过来时,走过去开门有点麻烦,而门禁软件需要每次进 ...
- pythoncad二次开发视频_revit二次开发|bim软件二次开发|revit二次开发教程|Revit二次开发技术文档...
二次开发 revit二次开发|bim软件二次开发|revit二次开发教程|Revit二次开发技术文档2019-07-08赞( 0 ) 记录一下CAD二次开发的一些简单实例. 1.helloworld ...
- 速达软件二次开发-销售开单结算单位和账期报表需求
接到某公司的二次开发需求如下: 1.销售开单中客户名称和结算单位做好匹配,提前在客户资料中录入结算单位资料,如下选择客户名称为"深圳瑞电"的时候结算单位自动跳出"义巍实业 ...
- 基于VB.NET的NX UG软件二次开发基础
本文已经首发在个人微信公众号:工业机器人仿真与编程(微信号:IndRobSim),欢迎关注! 前几期中为大家介绍了CATIA软件.AutoCAD软件基于VB.NET的二次开发,本期再来为大家介绍一下N ...
- c#获取autocad安装位置_Robotstudio软件二次开发:基于C#语言的Smart组件开发基础
Robotstudio软件除了支持Add-Ins插件的二次开发以外,还支持Smart组件的二次开发. 开发语言同样是基于 .NET框架的C#语言或VB语言. Smart组件是Robotstudio软件 ...
- ArcGIS二次开发基础教程(03):保存文档和导出地图
ArcGIS二次开发基础教程(03):保存文档和导出地图 保存文档 保存: //这里的path为全局变量 在打开文件获添加数据时赋值原路径 //判断打开文件是否为mxd文件 是则保存 不是则另存为 i ...
最新文章
- luogu P3378 【模板】堆
- 「后端小伙伴来学前端了」Element修改默认样式 | 记录自己学习前端踩坑日记
- OpenCV使用FacemarkAAM
- Java泛型(1)--集合使用泛型Generic、自定义泛型、泛型在继承上的体现、通配符的使用
- hdu 2110 基础母函数
- [css] 写一个动画,向上匀速移动100px,向下以1.5倍速度移动200px,一直反复循环
- 机器人踩滑板_不死神草、飞行滑板…超2000种创新发明在这里展出
- Spring Boot配置MinIO(实现文件上传、下载、删除)
- 找工作的迷茫期开始了
- 区块链酒廊BTC Lounge正式启动运营
- java的 交换排序 快速排序算法_数据结构之排序算法Java实现(4)—— 交换类排序之快速排序算法...
- 交叉验证和超参数调整:如何优化你的机器学习模型
- 上海市计算机二级vb试题及答案,上海市207计算机二级vb试题.doc
- 打印和为sum的组合,动规法+DFS+迭代法
- openGL实现太阳系行星系统
- Linux驱动开发系列之一:Ubuntu 8.10下编译Linux kernel 2.6.32.1
- wordpress友联_一段代码开启WordPress友情链接管理
- html table表格设置滚动条
- 网络环路检测定位技术的发展过程
- PyGame|给程序插入背景音乐